//
//  Inventory.m
//  A One POS
//
//  Created by AonePOS on 24/09/13.
//  Copyright (c) 2013 AonePOS. All rights reserved.
//

#import "Inventory.h"
#import "Settings.h"
#import "Home.h"
#import "Profile.h"
#import "Stores.h"
#import "Customers.h"
#import "Employees.h"
#import "Reports.h"
#import "Contacts.h"
#import "DataBaseManager.h"
#import "ServersyncClass.h"
#import "jobpagination.h"
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
@interface Inventory ()

@end

@implementation Inventory
{
    NSMutableArray *invoiceItemsArray;
      NSString *InvItemNumber,*vendorNumber;
    ServersyncClass *serverSyncClassObject;
     general_data *generalDataObject;
    jobpagination  *jobpaginationObject;
    pagination *paginationObject;
    Vendorpagination *vendorPaginationObject;
    Productpagination *productPaginationObject;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    generalDataObject =[general_data new];
    [generalDataObject  GetuserDataVariablesMethod];
    serverSyncClassObject=[ServersyncClass new];
    jobpaginationObject=[jobpagination new];
    paginationObject=[pagination new];
    vendorPaginationObject=[Vendorpagination new];
     productPaginationObject=[Productpagination new];
    [NSThread detachNewThreadSelector:@selector(ServerSyncronizationMethod) toTarget:serverSyncClassObject withObject:nil];
     //appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    [super viewDidLoad];
    
    y=0;
    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
    {
        y=y+20;
        
        
    }
    CGFloat width,height;
    width=self.view.frame.size.width;
    height=self.view.frame.size.height;
    // //NSLog(@" %f,%f",width,height);
    
    
    if (!backgroundcolorview)
    {
    backgroundcolorview=[[UIView alloc]init];
    backgroundcolorview.frame=CGRectMake(0,y,width,height-100);
    
    
    [backgroundcolorview  setBackgroundColor:[UIColor colorWithPatternImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"background" ofType:@"jpg"]]]];
    
    [self.view addSubview:backgroundcolorview];
    
    // [ContactsBtn setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"contactsactive" ofType:@"png"]] forState:UIControlStateNormal];
    
    sidemenu=[[UIView alloc]init];
    sidemenu.frame=CGRectMake(0, 1,170 ,height-150);
    //sidemenu.hidden=YES;
    //[sidemenu  setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bluecolorstrip.jpg"]]];
    [sidemenu  setBackgroundColor:[UIColor colorWithPatternImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bluecolorstrip" ofType:@"jpg"]]]];
    
    
    NSString *pagetitle;
    pagetitle=@"Inventory";
    
    
    
    navBar = [[UINavigationBar alloc] init];
    navBar.frame=CGRectMake(0, 0,width , 50.0);
    
    [navBar setBackgroundImage:[UIImage imageNamed:@"logo-login-bg-short.png"] forBarMetrics:UIBarMetricsDefault];
    
    //[navBar setBackgroundColor:[UIColor blackColor]];
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
    titleLabel.font=[UIFont boldSystemFontOfSize:30.0];
    titleLabel.textColor = [UIColor blackColor];
    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.text =pagetitle;
    [self.navigationItem setTitleView:titleLabel];
    
    pagetitle=nil;
    //navItem.title = pagetitle;
    [navBar pushNavigationItem:self.navigationItem animated:false];
    
    [backgroundcolorview addSubview:navBar];
    
    
    menubutton = [UIButton buttonWithType:UIButtonTypeCustom];
    [menubutton setFrame:CGRectMake(0,0,50,50)];
    [menubutton addTarget:self action:@selector(menuclicked) forControlEvents:UIControlEventTouchUpInside];
    
    [menubutton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"arrow" ofType:@"png"]] forState:UIControlStateNormal];
    [navBar addSubview:menubutton];
    
    
    logoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [logoBtn setFrame:CGRectMake(60,0,250,50)];
    // [logoBtn addTarget:self action:@selector(menuclicked) forControlEvents:UIControlEventTouchUpInside];
    
    //[logoBtn setImage:[UIImage imageNamed:@"headeraonelogo.png"] forState:UIControlStateNormal];
    [logoBtn setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"headeraonelogo" ofType:@"png"]] forState:UIControlStateNormal];
    
    [navBar addSubview:logoBtn];
    sationLbl=[[UILabel alloc] init];
    sationLbl.frame=CGRectMake(navBar.frame.size.width-280, 5,100, 40);
    [sationLbl setFont:[UIFont systemFontOfSize:13.0f]];
    [sationLbl setBackgroundColor:[UIColor clearColor]];
    [sationLbl setTextColor:[UIColor blackColor]];
    [sationLbl setText:@"Station No:1"];
    sationLbl.lineBreakMode = NSLineBreakByWordWrapping;
    sationLbl.numberOfLines = 2;
    [sationLbl setTextAlignment:NSTextAlignmentLeft];
    [navBar addSubview:sationLbl];
    
    
    EmpIdlbl=[[UILabel alloc] init];
    EmpIdlbl.frame=CGRectMake(navBar.frame.size.width-193, 5,150, 40);
    [EmpIdlbl setFont:[UIFont systemFontOfSize:13.0f]];
    [EmpIdlbl setBackgroundColor:[UIColor clearColor]];
    [EmpIdlbl setTextColor:[UIColor blackColor]];
    [EmpIdlbl setText:[NSString stringWithFormat:@"Employee Id: %@",[generalDataObject  userID]]];
    EmpIdlbl.lineBreakMode = NSLineBreakByWordWrapping;
    // EmpIdlbl.numberOfLines = 2;
    [EmpIdlbl setTextAlignment:NSTextAlignmentLeft];
    [navBar addSubview:EmpIdlbl];
    
    
    Timelbl=[[UILabel alloc] init];
    Timelbl.frame=CGRectMake(navBar.frame.size.width-62, 6,80, 40);
    [Timelbl setFont:[UIFont systemFontOfSize:13.0f]];
    [Timelbl setBackgroundColor:[UIColor clearColor]];
    [Timelbl setTextColor:[UIColor blackColor]];
    NSDate *aDate = [NSDate date];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterShortStyle];
    [formatter setTimeStyle:NSDateFormatterNoStyle];
    [formatter setDateFormat:@"HH:mm:ss"];
    NSString *datestr;
    datestr=[formatter stringFromDate:aDate];
    Timelbl.text=datestr;
    //Timelbl.text=[NSString stringWithFormat:@"%@:%@",@"Time",datestr];
    
    // timer is set & will be triggered each second
    //[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(showTime) userInfo:nil repeats:YES];
    Timelbl.lineBreakMode = NSLineBreakByWordWrapping;
    Timelbl.numberOfLines = 2;
    [Timelbl setTextAlignment:NSTextAlignmentLeft];
    [navBar addSubview:Timelbl];
    
    
    p=1;
    @autoreleasepool {
        for (int i=0; i< 10; i++)
        {
            
            categorybutton = [UIButton buttonWithType:UIButtonTypeCustom];
            
            [categorybutton setFrame:CGRectMake(0,p,170,40)];
            [categorybutton addTarget:self action:@selector(categotybuttonclicked:) forControlEvents:UIControlEventTouchUpInside];
            categorybutton.tag=i;
            if (categorybutton.tag == 0)
            {
                //[categorybutton setImage:[UIImage imageNamed:@"posnormal2.png"] forState:UIControlStateNormal];
                [categorybutton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"posnormal2" ofType:@"png"]] forState:UIControlStateNormal];
            }
            
            else if (categorybutton.tag == 1)
            {
                //[categorybutton setImage:[UIImage imageNamed:@"profilenormal2.png"] forState:UIControlStateNormal];
                
                [categorybutton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"profilenormal2" ofType:@"png"]] forState:UIControlStateNormal];
            }
            else if (categorybutton.tag == 2)
            {
                //[categorybutton setImage:[UIImage imageNamed:@"inventoryactive2.png"] forState:UIControlStateNormal];
                
                [categorybutton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"inventoryactive2" ofType:@"png"]] forState:UIControlStateNormal];
            }
            else if(categorybutton.tag == 3)
            {
                // [categorybutton setImage:[UIImage imageNamed:@"customernormal2.png"] forState:UIControlStateNormal];
                [categorybutton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"customernormal2" ofType:@"png"]] forState:UIControlStateNormal];
            }
            else if (categorybutton.tag == 4)
            {
                //[categorybutton setImage:[UIImage imageNamed:@"employeenormal2.png"] forState:UIControlStateNormal];
                [categorybutton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"employeenormal2" ofType:@"png"]] forState:UIControlStateNormal];
            }
            else if(categorybutton.tag == 5)
            {
                //[categorybutton setImage:[UIImage imageNamed:@"settingsnormal2.png"] forState:UIControlStateNormal];
                [categorybutton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"settingsnormal2" ofType:@"png"]] forState:UIControlStateNormal];
            }
            else if(categorybutton.tag == 6)
            {
                //[categorybutton setImage:[UIImage imageNamed:@"reportsnormal2.png"] forState:UIControlStateNormal];
                [categorybutton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"reportsnormal2" ofType:@"png"]] forState:UIControlStateNormal];
            }
            else if(categorybutton.tag == 7)
            {
                //[categorybutton setImage:[UIImage imageNamed:@"contactsnormal2.png"] forState:UIControlStateNormal];
                [categorybutton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"contactsnormal2" ofType:@"png"]] forState:UIControlStateNormal];
            }
            else if (categorybutton.tag == 8)
            {
                //[categorybutton setImage:[UIImage imageNamed:@"storesnormal.png"] forState:UIControlStateNormal];
                [categorybutton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"storesnormal" ofType:@"png"]] forState:UIControlStateNormal];
            }
            
            else if (categorybutton.tag == 9)
            {
                //[categorybutton setImage:[UIImage imageNamed:@"bluecolorstrip.jpg"] forState:UIControlStateNormal];
            }
            [sidemenu addSubview:categorybutton];
            p=p+categorybutton.frame.size.height;
            
        }
    }
    NSMutableArray *taxnamesArray,*taxratesArray;
   taxnamesArray=[[NSMutableArray alloc]init];
    taxratesArray=[[NSMutableArray alloc]init];
    
      NSString *querySQL2 = [NSString stringWithFormat:@"SELECT name,tax_value FROM taxes"];
        NSMutableArray *taxesArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL2 resultsArray:taxesArray];
   
    if ([taxesArray count]>0){
        for (NSDictionary *myDict in taxesArray)
        {
            
            [taxnamesArray addObject:[myDict objectForKey:@"name"]];
            [taxratesArray addObject:[myDict objectForKey:@"tax_value"]];
            
            
        }
        if ([taxnamesArray count]>0){
            
            tax1Name=[taxnamesArray objectAtIndex:0];
            tax1Rate=[taxratesArray objectAtIndex:0];
            
        }
        if ([taxnamesArray count]>1){
            
            tax2Name=[taxnamesArray objectAtIndex:1];
            tax2Rate=[taxratesArray objectAtIndex:1];
        }
        if ([taxnamesArray count]>2){
            tax3Name=[taxnamesArray objectAtIndex:2];
            tax3Rate=[taxratesArray objectAtIndex:2];
            
        }

    }
    
    
    mainview=[[UIView alloc]init];
    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
    {
        mainview.frame=CGRectMake(20,navBar.frame.size.height+10,width-40,height-200);
    }
    else
    {
        mainview.frame=CGRectMake(20,navBar.frame.size.height+20,width-40,height-200);
    }
    [mainview setBackgroundColor:[UIColor grayColor]];
    [mainview  setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"hqbackground69opacity.png"]]];
    [backgroundcolorview addSubview:mainview];
    maintoolBar = [[UIToolbar alloc] init];
    maintoolBar.frame = CGRectMake(0, 0, mainview.frame.size.width, 40);
    // [maintoolBar setBackgroundImage:[UIImage imageNamed:@"toprightmenu.png"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
    
    [maintoolBar setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"toprightmenu" ofType:@"png"]] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
    
    CGFloat buttnwidth=(mainview.frame.size.width)/4;
    
    NSMutableArray *items=[[NSMutableArray alloc]init];
    ProductBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    ProductBtn.frame = CGRectMake(0, 0, buttnwidth, 60);
    ProductBtn.selected=YES;
    [ProductBtn addTarget:self action:@selector(productbtnclicked) forControlEvents:UIControlEventTouchUpInside];
    // [backButton setBackgroundImage:[UIImage imageNamed:@"topright-highlightitem-textbg.png"] forState:UIControlStateNormal];
    UIImage *btnImg = [UIImage imageNamed:@"highlightedtopmenuitem.png"];
    btnGreyImg = [btnImg stretchableImageWithLeftCapWidth:0 topCapHeight:1];
    [ProductBtn setBackgroundImage:btnGreyImg forState:UIControlStateSelected];
    ProductBtn.tag=[items indexOfObject:ProductBtn];
    [ProductBtn setTitle:@"Product" forState:UIControlStateNormal];
    [ProductBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [ProductBtn setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
    
   // ProductBtn.showsTouchWhenHighlighted = YES;
    
    UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:ProductBtn];
    [items  addObject:backBarButtonItem];
    [items addObject:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]];
    DepartmentsBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    DepartmentsBtn.frame = CGRectMake(0, 0, buttnwidth, 60);
    [DepartmentsBtn setTitle:@"Department" forState:UIControlStateNormal];
    [DepartmentsBtn addTarget:self action:@selector(Deparmentbtnclicked) forControlEvents:UIControlEventTouchUpInside];
    DepartmentsBtn.selected=NO;
    [DepartmentsBtn setBackgroundImage:btnGreyImg forState:UIControlStateSelected];
    [DepartmentsBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [DepartmentsBtn setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
    DepartmentsBtn.tag=[items indexOfObject:DepartmentsBtn];
    //[backButton2 setBackgroundImage:[UIImage imageNamed:@"topright-highlightitem-textbg.png"] forState:UIControlStateNormal];
   // DepartmentsBtn.showsTouchWhenHighlighted = YES;
    
    
    UIBarButtonItem *backBarButtonItem2 = [[UIBarButtonItem alloc] initWithCustomView:DepartmentsBtn];
    
    [items  addObject:backBarButtonItem2];
    [items addObject:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]];
    CategoryBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    CategoryBtn.frame = CGRectMake(0, 0, buttnwidth,60);
    [CategoryBtn setTitle:@"Category" forState:UIControlStateNormal];
     CategoryBtn.selected=NO;
    [CategoryBtn setBackgroundImage:btnGreyImg forState:UIControlStateSelected];
    [CategoryBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [CategoryBtn setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
    [CategoryBtn addTarget:self action:@selector(categoryBtnclicked) forControlEvents:UIControlEventTouchUpInside];
    //[backButton3 setBackgroundImage:[UIImage imageNamed:@"topright-highlightitem-textbg.png"] forState:UIControlStateNormal];
    //CategoryBtn.showsTouchWhenHighlighted = YES;
    CategoryBtn.tag=[items indexOfObject:CategoryBtn];
    //UIImage *backButtonImage = [UIImage imageNamed:@"back-button.png"];
    //[backButton setImage:backButtonImage forState:UIControlStateNormal];
    
    // backButton.imageEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10);
    
    UIBarButtonItem *backBarButtonItem3 = [[UIBarButtonItem alloc] initWithCustomView:CategoryBtn];
    [items addObject:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]];
    [items  addObject:backBarButtonItem3];
    VendorsBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    VendorsBtn.frame = CGRectMake(0, 0, buttnwidth ,60);
    [VendorsBtn setTitle:@"Vendors" forState:UIControlStateNormal];
    [VendorsBtn setBackgroundImage:btnGreyImg forState:UIControlStateSelected];
    [VendorsBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [VendorsBtn setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
    [VendorsBtn addTarget:self action:@selector(vendorbtnclicked) forControlEvents:UIControlEventTouchUpInside];
       VendorsBtn.selected=NO;
    //[backButton3 setBackgroundImage:[UIImage imageNamed:@"topright-highlightitem-textbg.png"] forState:UIControlStateNormal];
   // VendorsBtn.showsTouchWhenHighlighted = YES;
    VendorsBtn.tag=[items indexOfObject:VendorsBtn];
    //UIImage *backButtonImage = [UIImage imageNamed:@"back-button.png"];
    //[backButton setImage:backButtonImage forState:UIControlStateNormal];
    
    // backButton.imageEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10);
    
    UIBarButtonItem *backBarButtonItem4 = [[UIBarButtonItem alloc] initWithCustomView:VendorsBtn];
    [items addObject:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]];
    [items  addObject:backBarButtonItem4];
    
    
    [maintoolBar setItems:items animated:NO];
    [mainview addSubview:maintoolBar];
    
    logoimageview=[[UIImageView alloc]init];
    logoimageview.frame=CGRectMake(50, (backgroundcolorview.frame.size.height)+5+y,(height-(backgroundcolorview.frame.size.height)-30), (height-(backgroundcolorview.frame.size.height)-30));
    [logoimageview setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"aoneposlogo" ofType:@"png"]]];
    [self.view addSubview:logoimageview];
    
    helpiconButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [helpiconButton setFrame:CGRectMake(width-180,y+40,70,70)];
    [helpiconButton addTarget:self action:@selector(helpiconclicked) forControlEvents:UIControlEventTouchUpInside];
    
    //[helpiconButton setImage:[UIImage imageNamed:@"helpicon.png"] forState:UIControlStateNormal];
    [helpiconButton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"helpicon" ofType:@"png"]] forState:UIControlStateNormal];
    
    [self.view addSubview:helpiconButton];
    logouticonButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [logouticonButton setFrame:CGRectMake(width-100,y+40,70,70)];
    [logouticonButton addTarget:self action:@selector(logoutButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    
    //[logouticonButton setImage:[UIImage imageNamed:@"logoutbutton.png"] forState:UIControlStateNormal];
    [logouticonButton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"logoutbutton" ofType:@"png"]] forState:UIControlStateNormal];
    [self.view addSubview:logouticonButton];
    
    
//product view
    
    ProductView=[[UIView alloc]init];
    ProductView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
    [ProductView setBackgroundColor:[UIColor whiteColor]];
    ProductView.layer.cornerRadius=8;
    [mainview addSubview:ProductView];
    
    AddProductBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    [AddProductBtn setTitle:@"Add Product" forState:UIControlStateNormal];
    
    CGFloat addbuttonwidth4=(ProductView.frame.size.width-5)/2;
    AddProductBtn.frame=CGRectMake(5, 10, addbuttonwidth4, 40);
    //[AddProductBtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
    [AddProductBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bluetabactive" ofType:@"png"]] forState:UIControlStateSelected];
     [AddProductBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     [AddProductBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
    //addtaxBtn.layer.cornerRadius=8;
    [AddProductBtn addTarget:self action:@selector(AddProductClicked) forControlEvents:UIControlEventTouchUpInside];
    AddProductBtn.selected=YES;
    [ProductView addSubview:AddProductBtn];
    
    EditProductBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    
    [EditProductBtn setTitle:@"View & Edit Product" forState:UIControlStateNormal];
    EditProductBtn.frame=CGRectMake(AddProductBtn.frame.size.width, 10, addbuttonwidth4, 40);
    //EditCategoryBtn.backgroundColor=[UIColor colorWithRed:203.0f green:203.0f/255.0f blue:203.0f/255.0f alpha:1.0f];
    [EditProductBtn setBackgroundColor:[UIColor whiteColor]];
    [EditProductBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditProductBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bluetabactive" ofType:@"png"]] forState:UIControlStateSelected];
    [EditProductBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditProductBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
    EditProductBtn.selected=NO;
    [EditProductBtn addTarget:self action:@selector(EditProductClicked) forControlEvents:UIControlEventTouchUpInside];
    [ProductView addSubview:EditProductBtn];
    //add product view
    AddProductScrollView=[[UIScrollView alloc]init];
    
    AddProductScrollView.frame=CGRectMake(5, AddProductBtn.frame.size.height+10, ProductView.frame.size.width-10, ProductView.frame.size.height-20-AddProductBtn.frame.size.height);
    [AddProductScrollView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    AddProductScrollView.contentSize=CGSizeMake(ProductView.frame.size.width-10, ProductView.frame.size.height-20-AddProductBtn.frame.size.height+500);
    
    [ProductView addSubview:AddProductScrollView];
    CGFloat Productfieldwidth=(AddProductScrollView.frame.size.width-100)/4;
    CGFloat r=(Productfieldwidth/2)+20;
    
    Departmentlbl=[[UILabel alloc] init];
    Departmentlbl.frame=CGRectMake(r-80, 30,Productfieldwidth, 50);
    
    [Departmentlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Departmentlbl setBackgroundColor:[UIColor clearColor]];
    [Departmentlbl setTextColor:[UIColor whiteColor]];
    [Departmentlbl setText:@"Department for this Item"];
    Departmentlbl.lineBreakMode = NSLineBreakByWordWrapping;
    Departmentlbl.numberOfLines = 2;
    [Departmentlbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:Departmentlbl];
        
    NSString *querySQL7 = [NSString stringWithFormat: @"SELECT department_id,department_totaltax,department_foodstampable FROM department_details"];
    NSMutableArray *depatmsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:depatmsArray];
        

      if (!DepartmentNamesArray)
    DepartmentNamesArray=[[NSMutableArray alloc]init];
    if (!depttaxesArray)
    depttaxesArray=[[NSMutableArray alloc]init];
    if (!deptfoodsArray)
    deptfoodsArray=[[NSMutableArray alloc]init];
    NSString *Dept;
    
    if ([depatmsArray count]>0)
    {
        for (NSDictionary *myDict in depatmsArray)
        {
            
            NSString *catname=[myDict objectForKey:@"department_id"];
            [DepartmentNamesArray addObject:catname];
            NSString *tax=[myDict objectForKey:@"department_totaltax"];
            [depttaxesArray addObject:tax];
            [deptfoodsArray addObject:[myDict objectForKey:@"department_foodstampable"]];
            catname=nil,tax=nil;
        }
        Dept=[DepartmentNamesArray objectAtIndex:0];
        
        Tax=[depttaxesArray objectAtIndex:0];
        foodstampable=[deptfoodsArray objectAtIndex:0];
    }
    
    DepartmentBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DepartmentBtn.frame=CGRectMake(Productfieldwidth+5, 30, Productfieldwidth-10, 40);
    [DepartmentBtn addTarget:self action:@selector(DepartmentBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [DepartmentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    // [DepartmentBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [DepartmentBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [DepartmentBtn setTitle:Dept  forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [AddProductScrollView addSubview:DepartmentBtn];
    
    DepartmentsTable = [[UITableView alloc] initWithFrame:CGRectMake(Productfieldwidth+5, 70, Productfieldwidth-10, 100) style:UITableViewStylePlain];
    DepartmentsTable.backgroundColor=[UIColor whiteColor];
    DepartmentsTable.delegate = self;
    DepartmentsTable.dataSource = self;
    DepartmentsTable.scrollEnabled = YES;
    DepartmentsTable.hidden=YES;
    [DepartmentsTable.layer setBorderWidth: 1.0];
    [DepartmentsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [AddProductScrollView addSubview:DepartmentsTable];
    
    ItemNumberlbl=[[UILabel alloc] init];
    ItemNumberlbl.frame=CGRectMake(r-80, 90,Productfieldwidth, 40);
    [ItemNumberlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [ItemNumberlbl setBackgroundColor:[UIColor clearColor]];
    [ItemNumberlbl setTextColor:[UIColor whiteColor]];
    [ItemNumberlbl setText:@"Item Number"];
    [ItemNumberlbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:ItemNumberlbl];
    
    ItemNumberField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    ItemNumberField.frame=CGRectMake(Productfieldwidth+5, 90,Productfieldwidth-10, 40);
    ItemNumberField.delegate=self;
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    ItemNumberField.leftView = paddingview;
    ItemNumberField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    ItemNumberField.leftViewMode = UITextFieldViewModeAlways;
    //[ItemNumberField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [ItemNumberField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    
    //[DepartmentBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [ItemNumberField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddProductScrollView addSubview:ItemNumberField];
    
    ItemNamelbl=[[UILabel alloc] init];
    ItemNamelbl.frame=CGRectMake(r-80, 150,Productfieldwidth, 40);
    [ItemNamelbl setFont:[UIFont systemFontOfSize:20.0f]];
    [ItemNamelbl setBackgroundColor:[UIColor clearColor]];
    [ItemNamelbl setTextColor:[UIColor whiteColor]];
    [ItemNamelbl setText:@"Item Name"];
    [ItemNamelbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:ItemNamelbl];
    
    ItemNameField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    ItemNameField.frame=CGRectMake(Productfieldwidth+5, 150,Productfieldwidth-10, 40);
    ItemNameField.delegate=self;
    UIView *paddingview2=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    ItemNameField.leftView = paddingview2;
    ItemNameField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    ItemNameField.leftViewMode = UITextFieldViewModeAlways;
    //[ItemNameField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [ItemNameField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [ItemNameField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddProductScrollView addSubview:ItemNameField];
    
    Descroptionlbl=[[UILabel alloc] init];
    Descroptionlbl.frame=CGRectMake(r-80, 210,Productfieldwidth+10, 40);
    [Descroptionlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Descroptionlbl setBackgroundColor:[UIColor clearColor]];
    [Descroptionlbl setTextColor:[UIColor whiteColor]];
    [Descroptionlbl setText:@"2nd Description"];
    [Descroptionlbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:Descroptionlbl];
    
    DescriptionText=[[UITextView alloc] init];
    DescriptionText.frame=CGRectMake(Productfieldwidth+5, 200,Productfieldwidth-10,80);
    DescriptionText.delegate=self;
    DescriptionText.font=[UIFont systemFontOfSize:14.0f];
    [DescriptionText setAutocorrectionType:UITextAutocorrectionTypeNo];
    DescriptionText.layer.cornerRadius=8;
    [AddProductScrollView addSubview:DescriptionText];
    
    Costlbl=[[UILabel alloc] init];
    Costlbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15, 30,Productfieldwidth+10, 40);
    [Costlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Costlbl setBackgroundColor:[UIColor clearColor]];
    [Costlbl setTextColor:[UIColor whiteColor]];
    
    [Costlbl setText:@"Cost"];
    [Costlbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:Costlbl];
    
    CostField=[[UITextField alloc] init];
    CostField.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5, 30,Productfieldwidth-10, 40);
    [CostField addTarget:self action:@selector(AddressFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
    CostField.delegate=self;
    UIView *paddingview3=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    CostField.leftView = paddingview3;
    CostField.keyboardType=UIKeyboardTypeNumberPad;
    CostField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    CostField.leftViewMode = UITextFieldViewModeAlways;
    //[CostField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [CostField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    
    [CostField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddProductScrollView addSubview:CostField];
    
    priceyouChargelbl=[[UILabel alloc] init];
    priceyouChargelbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15,90,Productfieldwidth+10, 40);
    [priceyouChargelbl setFont:[UIFont systemFontOfSize:20.0f]];
    [priceyouChargelbl setBackgroundColor:[UIColor clearColor]];
    [priceyouChargelbl setTextColor:[UIColor whiteColor]];
    
    [priceyouChargelbl setText:@"Price You Charge"];
    [priceyouChargelbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:priceyouChargelbl];
    
    PriceyouChargeField=[[UITextField alloc] init];
    PriceyouChargeField.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,90,Productfieldwidth-10, 40);
    [PriceyouChargeField addTarget:self action:@selector(PriceYouChargeClicked:) forControlEvents:UIControlEventEditingDidEnd];
    PriceyouChargeField.delegate=self;
    UIView *paddingview4=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    PriceyouChargeField.leftView = paddingview4;
    PriceyouChargeField.keyboardType=UIKeyboardTypeNumberPad;
    PriceyouChargeField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    PriceyouChargeField.leftViewMode = UITextFieldViewModeAlways;
    //[PriceyouChargeField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [PriceyouChargeField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [PriceyouChargeField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddProductScrollView addSubview:PriceyouChargeField];
    
    priceWithTaxlbl=[[UILabel alloc] init];
    priceWithTaxlbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15,150,Productfieldwidth+10, 40);
    [priceWithTaxlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [priceWithTaxlbl setBackgroundColor:[UIColor clearColor]];
    [priceWithTaxlbl setTextColor:[UIColor whiteColor]];
    
    [priceWithTaxlbl setText:@"Price with Tax"];
    [priceWithTaxlbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:priceWithTaxlbl];
    
    PriceWithTaxBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    PriceWithTaxBtn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,150,Productfieldwidth-10, 40);
    [PriceWithTaxBtn addTarget:self action:@selector(pricewithTaxClicked) forControlEvents:UIControlEventTouchUpInside];
    
    [PriceWithTaxBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [PriceWithTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]] forState:UIControlStateNormal];
    [AddProductScrollView addSubview:PriceWithTaxBtn];
    
    InStocklbl=[[UILabel alloc] init];
    InStocklbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15,210,Productfieldwidth+10, 40);
    [InStocklbl setFont:[UIFont systemFontOfSize:20.0f]];
    [InStocklbl setBackgroundColor:[UIColor clearColor]];
    [InStocklbl setTextColor:[UIColor whiteColor]];
    
    [InStocklbl setText:@"In Stock"];
    [InStocklbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:InStocklbl];
    
    InStockField=[[UITextField alloc] init];
    InStockField.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,210,Productfieldwidth-10, 40);
    [InStockField addTarget:self action:@selector(AddressFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
    InStockField.delegate=self;
    UIView *paddingview5=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    InStockField.leftView = paddingview5;
    InStockField.keyboardType=UIKeyboardTypeNumberPad;
    InStockField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    InStockField.leftViewMode = UITextFieldViewModeAlways;
    // [InStockField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [InStockField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [InStockField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddProductScrollView addSubview:InStockField];
    
    Addpricinglbl=[[UILabel alloc] init];
    Addpricinglbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15,270,Productfieldwidth+10, 50);
    [Addpricinglbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Addpricinglbl setBackgroundColor:[UIColor clearColor]];
    [Addpricinglbl setTextColor:[UIColor whiteColor]];
    
    [Addpricinglbl setText:@"Addpricing from a Vendor"];
    Addpricinglbl.lineBreakMode = NSLineBreakByWordWrapping;
    Addpricinglbl.numberOfLines = 2;
    [Addpricinglbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:Addpricinglbl];
        
    if (!VendornumbersArray)
    VendornumbersArray=[[NSMutableArray alloc]init];
    NSString *querySQL = [NSString stringWithFormat: @"SELECT vendor_no FROM vendor"];
    NSMutableArray *vendorsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:vendorsArray];
        
    @autoreleasepool {
            for (NSDictionary *myDict in vendorsArray)
            {
                NSString *vendorno=[myDict objectForKey:@"vendor_no"];
                
                [VendornumbersArray addObject:vendorno];
            }

        }
    AddpricingBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    AddpricingBtn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,270,Productfieldwidth-10, 40);
    [AddpricingBtn addTarget:self action:@selector(AddpricingClicked) forControlEvents:UIControlEventTouchUpInside];
    // [AddpricingBtn setTitle:[VendornumbersArray objectAtIndex:0] forState:UIControlStateNormal];
    [AddpricingBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[AddpricingBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [AddpricingBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    
    [AddProductScrollView addSubview:AddpricingBtn];
    
    
    VendorsTable = [[UITableView alloc] initWithFrame:CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,170,Productfieldwidth-10, 100) style:UITableViewStylePlain];
    VendorsTable.backgroundColor=[UIColor whiteColor];
    VendorsTable.delegate = self;
    VendorsTable.dataSource = self;
    VendorsTable.scrollEnabled = YES;
    VendorsTable.hidden=YES;
    [VendorsTable.layer setBorderWidth: 1.0];
    [VendorsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [AddProductScrollView addSubview:VendorsTable];
    
    tax1Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    tax1Btn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+10,35,30, 30);
    [tax1Btn addTarget:self action:@selector(Tax1Clicked) forControlEvents:UIControlEventTouchUpInside];
    [tax1Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[tax1Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [tax1Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    //[tax1Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [tax1Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [AddProductScrollView addSubview:tax1Btn];
    
    tax1lbl=[[UILabel alloc] init];
    tax1lbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+45,30,50, 40);
    [tax1lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [tax1lbl setBackgroundColor:[UIColor clearColor]];
    [tax1lbl setTextColor:[UIColor whiteColor]];
    tax1Btn.selected=YES;
    [tax1lbl setText:tax1Name];
    
    [tax1lbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:tax1lbl];
    
    
    tax2Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    tax2Btn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+10,95,30, 30);
    [tax2Btn addTarget:self action:@selector(Tax2Clikced) forControlEvents:UIControlEventTouchUpInside];
    [tax2Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[tax2Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [tax2Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    //[tax2Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [tax2Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    
    [AddProductScrollView addSubview:tax2Btn];
    
    tax2lbl=[[UILabel alloc] init];
    tax2lbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+45,90,50, 40);
    [tax2lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [tax2lbl setBackgroundColor:[UIColor clearColor]];
    [tax2lbl setTextColor:[UIColor whiteColor]];
    
    [tax2lbl setText:tax2Name];
    
    [tax2lbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:tax2lbl];
    
    tax3Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    tax3Btn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+10,155,30, 30);
    [tax3Btn addTarget:self action:@selector(Tax3Clicked) forControlEvents:UIControlEventTouchUpInside];
    [tax3Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[tax3Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [tax3Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    //[tax3Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [tax3Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [AddProductScrollView addSubview:tax3Btn];
    
    tax3lbl=[[UILabel alloc] init];
    tax3lbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+45,150,50, 40);
    [tax3lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [tax3lbl setBackgroundColor:[UIColor clearColor]];
    [tax3lbl setTextColor:[UIColor whiteColor]];
    
    [tax3lbl setText:tax3Name];
    
    [tax3lbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:tax3lbl];
    
    BarTaxBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    BarTaxBtn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+10,215,30, 30);
    [BarTaxBtn addTarget:self action:@selector(BarBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [BarTaxBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[BarTaxBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[BarTaxBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    
    [BarTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    //[tax3Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [BarTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    [AddProductScrollView addSubview:BarTaxBtn];
    [self settaxSelectionMethod];
    bartaxlbl=[[UILabel alloc] init];
    bartaxlbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+45,210,80, 40);
    [bartaxlbl setFont:[UIFont systemFontOfSize:18.0f]];
    [bartaxlbl setBackgroundColor:[UIColor clearColor]];
    [bartaxlbl setTextColor:[UIColor whiteColor]];
    [bartaxlbl setText:@"Bartax"];
    [bartaxlbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:bartaxlbl];
    CGFloat wdth=(AddProductScrollView.frame.size.width)/4;
    CGFloat xvalue=wdth/4;
         NSArray *array3=[[NSArray alloc]initWithObjects:@"Ordering Info",@"SalesHistory", @"printers",nil];
          NSArray *array2=[[NSArray alloc]initWithObjects:@"Optional Info",@"Notes",@"Modifiers",nil];
    for (int k=0; k<3; k++)
    {
        infoButtons = [UIButton buttonWithType:UIButtonTypeRoundedRect];
      
        [infoButtons setTitle:[array2 objectAtIndex:k] forState:UIControlStateNormal];
        //[infoButtons setBackgroundImage:[UIImage imageNamed:@"additionaloptions.png"] forState:UIControlStateNormal];
        [infoButtons setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"additionaloptions" ofType:@"png"]] forState:UIControlStateNormal];
        infoButtons.frame=CGRectMake(xvalue+20,350,wdth+5, 40);
        
        [infoButtons addTarget:self action:@selector(infoButton1Clicked:) forControlEvents:UIControlEventTouchUpInside];
        infoButtons.tag=k+100;
        [infoButtons setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        [AddProductScrollView addSubview:infoButtons];
        xvalue=xvalue+wdth+15;
        
    }
    
    CGFloat wdth2=(AddProductScrollView.frame.size.width)/4;
    CGFloat valuex=wdth2/4;
    for (int j=0; j<3; j++)
    {
        infoButton2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
       
        [infoButton2 setTitle:[array3 objectAtIndex:j] forState:UIControlStateNormal];
        //[infoButton2 setBackgroundImage:[UIImage imageNamed:@"additionaloptions.png"] forState:UIControlStateNormal];
        [infoButton2 setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"additionaloptions" ofType:@"png"]] forState:UIControlStateNormal];
        
        infoButton2.frame=CGRectMake(valuex+20,400,wdth2+5, 40);
        [infoButton2 addTarget:self action:@selector(infoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
        
        [infoButton2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        infoButton2.tag=j+100;
        if (infoButton2.tag==102)
        {
            infoButton2.hidden=YES;
        }
        [AddProductScrollView addSubview:infoButton2];
        
        valuex=valuex+wdth2+15;
        
    }
    
      
    SaveProductBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    SaveProductBtn.frame=CGRectMake(Productfieldwidth+140, 500, 80, 30);
    [SaveProductBtn addTarget:self action:@selector(SaveProductData) forControlEvents:UIControlEventTouchUpInside];
    
    //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
    [SaveProductBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //[SaveProductBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
    [SaveProductBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
    
    [AddProductScrollView addSubview:SaveProductBtn];
    
    CancelProductBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    CancelProductBtn.frame=CGRectMake(Productfieldwidth+240, 500, 80, 30);
    [CancelProductBtn addTarget:self action:@selector(CancelProductData) forControlEvents:UIControlEventTouchUpInside];
    [CancelProductBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //[CancelProductBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
    [CancelProductBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [AddProductScrollView addSubview:CancelProductBtn];
    
    
    
    
    //edit product view
    
    
    // UILabel *Catlbl,*Deptlbl;
    //  UIButton *Gobtn,*ResultspersetBtn;
    // UITextField *CatField,*DeptField,*SerachFieild;
    EditProductBackView=[[UIView alloc]init];
    
    EditProductBackView.frame=CGRectMake(5, AddProductBtn.frame.size.height+10, ProductView.frame.size.width-10, ProductView.frame.size.height-20-AddProductBtn.frame.size.height);
    
    [EditProductBackView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    
    
    CGFloat SearchW=(ProductView.frame.size.width-10)/2;
    CGFloat SW=SearchW/2;
    
    Catlbl=[[UILabel alloc] init];
    Catlbl.frame=CGRectMake(5,5,SW-20,40);
    [Catlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Catlbl setBackgroundColor:[UIColor clearColor]];
    [Catlbl setTextColor:[UIColor whiteColor]];
    [Catlbl setText:@"Category"];
    [Catlbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductBackView addSubview:Catlbl];
    
    
    CatField = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    CatField.frame=CGRectMake(Catlbl.frame.size.width,5,SW+15,35);
    [CatField addTarget:self action:@selector(CategorySelectedBtn) forControlEvents:UIControlEventTouchUpInside];
    [CatField setTitle:@"All"  forState:UIControlStateNormal];
    
    [CatField setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[CatField setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [CatField setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [EditProductBackView addSubview:CatField];
    
    Deptlbl=[[UILabel alloc] init];
    Deptlbl.frame=CGRectMake(5,45,SW-20, 40);
    [Deptlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Deptlbl setBackgroundColor:[UIColor clearColor]];
    [Deptlbl setTextColor:[UIColor whiteColor]];
    [Deptlbl setText:@"Department"];
    [Deptlbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductBackView addSubview:Deptlbl];
    
    
    DeptField = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    DeptField.frame=CGRectMake(Deptlbl.frame.size.width,45,SW+15, 40);
    [DeptField addTarget:self action:@selector(DepartmentSelectedBtn) forControlEvents:UIControlEventTouchUpInside];
    
    [DeptField setTitle:@"All" forState:UIControlStateNormal];
    
    [DeptField setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DeptField setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [DeptField setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [EditProductBackView addSubview:DeptField];
    
    Searchlbl=[[UILabel alloc] init];
    Searchlbl.frame=CGRectMake(5,90,SW-20, 40);
    [Searchlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Searchlbl setBackgroundColor:[UIColor clearColor]];
    [Searchlbl setTextColor:[UIColor whiteColor]];
    [Searchlbl setText:@"Search"];
    [Searchlbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductBackView addSubview:Searchlbl];
    
    SearchField=[[UITextField alloc] init];
    SearchField.frame=CGRectMake(Deptlbl.frame.size.width,90,SW+15, 40);
    [SearchField addTarget:self action:@selector(AddressFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
    SearchField.delegate=self;
    UIView *paddingview10=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    SearchField.leftView = paddingview10;
    SearchField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    SearchField.leftViewMode = UITextFieldViewModeAlways;
    //[SearchField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [SearchField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    
    [SearchField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditProductBackView addSubview:SearchField];
    
    SearchlistTable = [[UITableView alloc] initWithFrame:CGRectMake(Deptlbl.frame.size.width,5,SW+15, 90) style:UITableViewStylePlain];
    SearchlistTable.backgroundColor=[UIColor whiteColor];
    SearchlistTable.delegate = self;
    SearchlistTable.dataSource = self;
    SearchlistTable.scrollEnabled = YES;
    SearchlistTable.hidden=YES;
    [SearchlistTable.layer setBorderWidth: 1.0];
    [SearchlistTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditProductBackView addSubview:SearchlistTable];
    
    Gobtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    Gobtn.frame=CGRectMake(Deptlbl.frame.size.width+SearchField.frame.size.width+5,45,40, 40);
    [Gobtn addTarget:self action:@selector(GoBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    
    [Gobtn setTitle:@"Go" forState:UIControlStateNormal];
    [Gobtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //[Gobtn setBackgroundImage:[UIImage imageNamed:@"okay-button.png"] forState:UIControlStateNormal];
    [Gobtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"okay-button" ofType:@"png"]] forState:UIControlStateNormal];
    
    [EditProductBackView addSubview:Gobtn];
    
    
    displaylbl=[[UILabel alloc] init];
    displaylbl.frame=CGRectMake(Deptlbl.frame.size.width+SearchField.frame.size.width+5,5,SW, 40);
    [displaylbl setFont:[UIFont systemFontOfSize:20.0f]];
    [displaylbl setBackgroundColor:[UIColor clearColor]];
    [displaylbl setTextColor:[UIColor whiteColor]];
    [displaylbl setText:@"Display No of Sets"];
    [displaylbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductBackView addSubview:displaylbl];
    
    
    NSString *invCountSQL = [NSString stringWithFormat:@"select count(*) as totalcount from inventorytable"];
        NSMutableArray *countArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:invCountSQL resultsArray:countArray];
        ////NSLog(@"count %@",countArray);
    NSDictionary *dict=[countArray objectAtIndex:0];
        
    int inventorycount=[[dict objectForKey:@"totalcount"] intValue];
    [productPaginationObject  ResultsPerset:inventorycount];
    ResultspersetBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    ResultspersetBtn.frame=CGRectMake(Deptlbl.frame.size.width+SearchField.frame.size.width+5+displaylbl.frame.size.width,5,SW, 40);
    [ResultspersetBtn addTarget:self action:@selector(ResultspersetBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    if ([[productPaginationObject  ResultspersetArray] count]>0) {
        [ResultspersetBtn setTitle:[[productPaginationObject  ResultspersetArray] objectAtIndex:0] forState:UIControlStateNormal];
    }
    
    [ResultspersetBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[ResultspersetBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [ResultspersetBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [EditProductBackView addSubview:ResultspersetBtn];
    
    
    DisplaySettable = [[UITableView alloc] initWithFrame:CGRectMake(Deptlbl.frame.size.width+SearchField.frame.size.width+5+displaylbl.frame.size.width,45,SW, 80) style:UITableViewStylePlain];
    DisplaySettable.backgroundColor=[UIColor whiteColor];
    DisplaySettable.delegate = self;
    DisplaySettable.dataSource = self;
    DisplaySettable.scrollEnabled = YES;
    DisplaySettable.hidden=YES;
    [DisplaySettable.layer setBorderWidth: 1.0];
    [DisplaySettable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditProductBackView addSubview:DisplaySettable];
    

    // NSString *querySQL = [NSString stringWithFormat: @"SELECT * FROM inventorytable WHERE inventory_item_no='%@'",ProductNumber];
    NSString  *strp=[NSString stringWithFormat:@"%@",ResultspersetBtn.titleLabel.text];
    // //NSLog(@"result  btn str %@",strp);
    NSArray *array=[strp componentsSeparatedByString:@"-"];
    
    strp=[array objectAtIndex:0];
    // // //NSLog(@"string value %@",strp);
    int str=[strp intValue];
    // NSString *limit=[array objectAtIndex:1];
    strp=nil;
    NSString *selectsql=[NSString stringWithFormat:@"SELECT inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id FROM inventorytable limit 50 offset %d",str-1];
    // // //NSLog(@" seletced query %@",selectsql);
    NSMutableArray *productArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:selectsql resultsArray:productArray];
   
    selectsql=nil;
    NSMutableArray *rdarray=productArray;
    
   // NSMutableArray *updateTableArray3=[[NSMutableArray alloc] init];
    
    [productPaginationObject  setCompleteresultset:rdarray];
    
    [productPaginationObject   paginationinitializer:rdarray :10];
    
    [productPaginationObject  paginationsegment].tintColor=[UIColor whiteColor];
    [[productPaginationObject  paginationsegment] setFrame:CGRectMake(0,140 ,EditProductBackView.frame.size.width, 40)];
    
    [[productPaginationObject  paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
    
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [productPaginationObject  paginationsegment].selectedSegmentIndex=selectedsegindex;
    //updateTableArray3=[productPaginationObject  activateResults:selectedsegindex];
    [EditProductBackView addSubview:[productPaginationObject  paginationsegment]];
    
    
    editProductTable=[[UITableView alloc]init];
    //[editProductTable  setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    [editProductTable setBackgroundColor:[UIColor clearColor]];
    editProductTable.frame=CGRectMake(0,180 ,EditProductBackView.frame.size.width, EditProductBackView.frame.size.height-180);
    
    //editProductTable.contentSize = CGSizeMake(ProductView.frame.size.width+1000, ProductView.frame.size.height+1000);
    editProductTable.delegate=self;
    editProductTable.dataSource=self;
    
    [EditProductBackView addSubview:editProductTable];
    
    
    
    
    isLandScope = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
    [self updateUI];
    
    [self Totaltaxmethod];
    
   
    
  /*  vendorNO=[[NSString alloc]init];
    Terms=[[NSString alloc]init];
    minimumOrder=[[NSString alloc]init];
    commission=[[NSString alloc]init];
    FlatRent=[[NSString alloc]init];
    Companyname=[[NSString alloc]init];
    TaxtID=[[NSString alloc]init];
    state=[[NSString alloc]init];
    Billable=[[NSString alloc]init];
    Socialsecurity=[[NSString alloc]init];
    Zipcode=[[NSString alloc]init];
    streetAddress=[[NSString alloc]init];
    ExtendedAddress=[[NSString alloc]init];
    City=[[NSString alloc]init];
    country=[[NSString alloc]init];
    firstname=[[NSString alloc]init];
    lastname=[[NSString alloc]init];
    phNUmber=[[NSString alloc]init];
    faxnumber=[[NSString alloc]init];
    email=[[NSString alloc]init];
    website=[[NSString alloc]init];
    
    ChangevendorNO=[[NSString alloc]init];
    ChangeTerms=[[NSString alloc]init];
    ChangeminimumOrder=[[NSString alloc]init];
    Changecommission=[[NSString alloc]init];
    ChangeFlatRent=[[NSString alloc]init];
    ChangeCompanyname=[[NSString alloc]init];
    ChangeTaxtID=[[NSString alloc]init];
    Changestate=[[NSString alloc]init];
    ChangeBillable=[[NSString alloc]init];
    ChangeSocialsecurity=[[NSString alloc]init];
    ChangeZipcode=[[NSString alloc]init];
    ChangestreetAddress=[[NSString alloc]init];
    ChangeExtendedAddress=[[NSString alloc]init];
    ChangeCity=[[NSString alloc]init];
    Changecountry=[[NSString alloc]init];
    Changefirstname=[[NSString alloc]init];
    Changelastname=[[NSString alloc]init];
    ChangephNUmber=[[NSString alloc]init];
    Changefaxnumber=[[NSString alloc]init];
    Changeemail=[[NSString alloc]init];
    Changewebsite=[[NSString alloc]init];
    
    costStr=[[NSString alloc]init];
    tax1Str=[[NSString alloc]init];
    tax2Str=[[NSString alloc]init];
    tax3Str=[[NSString alloc]init];
    bartaxStr=[[NSString alloc]init];
    totalTaxStr=[[NSString alloc]init];
    
    ModifierItemNosArray=[[NSMutableArray alloc]init];
    modifierNamesArray=[[NSMutableArray alloc]init];*/
    if (!SkusArray)
     SkusArray=[[NSMutableArray alloc]init];
    if (!OptCommissionsArray)
    OptCommissionsArray=[[NSMutableArray alloc]initWithObjects:@"%Grassprofit",@"%Gross",@"Amount", nil];
    
    SelectedOpVendorsArray=[[NSMutableArray alloc] init];
    VendorPartsArray=[[NSMutableArray alloc] init];
    CostpersArray=[[NSMutableArray alloc] init];
    CasecostsArray=[[NSMutableArray alloc] init];
    NumberincasesArray=[[NSMutableArray alloc] init];
    preferredsArray=[[NSMutableArray alloc] init];
    
    
    [ItemNumberField setReturnKeyType:UIReturnKeyNext];
    [ItemNameField setReturnKeyType:UIReturnKeyNext];
    [DescriptionText setReturnKeyType:UIReturnKeyNext];
    [CostField setReturnKeyType:UIReturnKeyNext];
    [PriceyouChargeField setReturnKeyType:UIReturnKeyNext];
    [InStockField setReturnKeyType:UIReturnKeyDone];
        backBarButtonItem=nil,backBarButtonItem2=nil,backBarButtonItem3=nil,backBarButtonItem4=nil;btnImg=nil,btnGreyImg=nil;
         paddingview=nil,paddingview2=nil,paddingview3=nil,paddingview4=nil,paddingview5=nil,paddingview10=nil;
    }
    
      vendorNO=Terms=minimumOrder=commission=Companyname=FlatRent=TaxtID=Billable=Socialsecurity=streetAddress=ExtendedAddress=City=state=Zipcode=country=firstname=lastname=phNUmber=faxnumber=email=website=@"";
    // Do any additional setup after loading the view from its nib.
    
    modifierItem=@"no";
    CountthisItem=@"no";
    allowbuyback=@"no";
    printonreceipt=@"no";
    foodstampable=@"no";
    Promptprice=@"no";
    Productnotes=@"";
    Promptprice=@"";
    OPBarcodes=@"";
    OPBonusPoints=@"";
    OPlocation=@"";
    OPunittype=@"";
    OPunitsize=@"";
    OPCommission=@"";
    
    Editfoodstampable=@"";
    
     helpiconButton.hidden=YES;
    
    Editbonuspoint=Editbarcode=Editlocation=Editunitsize=EditUnittype=Editcommission=EditmodifierItem=EditCountthisItem=Editallowbuyback=Editpromptprice=Editprintonreceipt=Editfoodstampable=@"";
    
}
-(void)releaseDepartment
{
    
    NSArray * depertmentViewArray = depertmentView.subviews;
    for (int i = 0; i<[depertmentViewArray count]; i++) {
        UIView *vi =[depertmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addDepartmentViewArray = addDepartmentView.subviews;
    for (int i = 0; i<[addDepartmentViewArray count]; i++) {
        UIView *vi =[addDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addDepartmentView removeFromSuperview],[depertmentView removeFromSuperview];
    depertmentView=nil;
    //add deparment
    addDepartmentView=nil;
    addDeptbtn=nil,Editdeptbtn=nil;
    CatforthisDeptBtn=nil;
    IDfield=nil;
    deptIDlbl=nil,deptdesLbl=nil,deptcatidlbl=nil;
    deptDestextView=nil;
    savedeptBtn=nil,canceldeptbtn=nil;
    EditDeptTable=nil;
    categorysListTable=nil,PrinterslistTable=nil;
    [departmentIDsArray removeAllObjects],[DepartmentDesArray removeAllObjects],[DepartmentNamesArray removeAllObjects],[DeptCatIdsArray removeAllObjects],[deptprintersArray removeAllObjects],[deptfoodsArray removeAllObjects],[depttaxesArray removeAllObjects];
    departmentIDsArray=nil,DepartmentNamesArray=nil,DepartmentDesArray=nil,DeptCatIdsArray=nil,deptprintersArray=nil,deptfoodsArray=nil,depttaxesArray=nil;
    dataEditBtn=nil,dataDeleteBtn=nil,DuplicateBtn=nil;
    Deptax1Btn=nil,Deptax2Btn=nil,Deptax3Btn=nil,DepBarTaxBtn=nil,DeptfoodstampleBtn=nil,DeptprinterBtn=nil;
    Deptax1lbl=nil,Deptax2lbl=nil,Deptax3lbl=nil,Depbartaxlbl=nil,DeptFoodstampablelbl=nil,Deptprinterlbl=nil;
    deleteDeptAlert=nil;
    DepTaxValueStr=nil,Deptfoodstampable=nil;
    [PrinterslistArray removeAllObjects],[MinitsArray removeAllObjects];
    PrinterslistArray=nil;
    MinitsArray=nil;
    TimeForDeptlbl=nil;
    MinitBtn=nil,SecsBtn=nil;
    MinitslistTable=nil,SecslistTable=nil;
    [TimesArray removeAllObjects];
    TimesArray=nil;
    
    //edit department
    NSArray * editDepartmentpopupArray = editDepartmentpopup.subviews;
    for (int i = 0; i<[editDepartmentpopupArray count]; i++) {
        UIView *vi =[editDepartmentpopupArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *EditDepartmentViewArray = EditDepartmentView.subviews;
    for (int i = 0; i<[EditDepartmentViewArray count]; i++) {
        UIView *vi =[EditDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditDepartmentView removeFromSuperview],[editDepartmentpopup removeFromSuperview];
    EditDepartmentView=nil;
    editDepartmentpopup=nil;
    ChangeaddDeptbtn=nil,ChangeEditdeptbtn=nil;
    ChangeCatforthisDeptBtn=nil;
    ChangeIDfield=nil;
    ChangecategorysListTable=nil,ChangePrinterslistTable=nil;
    ChangedeptIDlbl=nil,ChangedeptdesLbl=nil,Changedeptcatidlbl=nil;
    ChangedeptDestextView=nil;
    ChangesavedeptBtn=nil,Changecanceldeptbtn=nil;
    nameDept=nil,idDept=nil,desDept=nil;
    ChangedataEditBtn=nil,ChangedataDeleteBtn=nil,ChangeDuplicateBtn=nil;
    ChangeDeptax1Btn=nil,ChangeDeptax2Btn=nil,ChangeDeptax3Btn=nil,ChangeDepBarTaxBtn=nil,ChangeDeptfoodstampleBtn=nil,ChangeDeptprinterBtn=nil;
    ChangeDeptax1lbl=nil,ChangeDeptax2lbl=nil,ChangeDeptax3lbl=nil,ChangeDepbartaxlbl=nil,ChangeDeptFoodstampablelbl=nil,ChangeDeptprinterlbl=nil;
    EditDeptfoodstampable=nil;
    
    ChangeTimeForDeptlbl=nil;
    ChangeMinitBtn=nil,ChangeSecsBtn=nil;
    ChangeMinitslistTable=nil,ChangeSecslistTable=nil;
}
-(void)viewWillAppear:(BOOL)animated

{
    isLandScope = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
    [self updateUI];
    // NSString *Dept;
    if (!pastDataArray)
    pastDataArray=[[NSMutableArray alloc]init];
    if (!SearchDataArray)
    SearchDataArray=[[NSMutableArray alloc]init];
    
    NSString *querySQL7 = [NSString stringWithFormat: @"SELECT department_id,department_totaltax,department_foodstampable FROM department_details"];
    NSMutableArray *depatmsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:depatmsArray];
    
    
    if (!DepartmentNamesArray)
        DepartmentNamesArray=[[NSMutableArray alloc]init];
    if (!depttaxesArray)
        depttaxesArray=[[NSMutableArray alloc]init];
    if (!deptfoodsArray)
        deptfoodsArray=[[NSMutableArray alloc]init];
    NSString *Dept;
    
    if ([depatmsArray count]>0)
    {
        for (NSDictionary *myDict in depatmsArray)
        {
            NSString *catname=[myDict objectForKey:@"department_id"];
            [DepartmentNamesArray addObject:catname];
            NSString *tax=[myDict objectForKey:@"department_totaltax"];
            [depttaxesArray addObject:tax];
            [deptfoodsArray addObject:[myDict objectForKey:@"department_foodstampable"]];
            catname=nil,tax=nil;
        }
        Dept=[DepartmentNamesArray objectAtIndex:0];
        
        Tax=[depttaxesArray objectAtIndex:0];
        foodstampable=[deptfoodsArray objectAtIndex:0];
    }
        
          NSString *querySQL = [NSString stringWithFormat: @"SELECT inventory_item_no,inventary_item_name FROM inventorytable"];
          NSMutableArray *productArray=[[NSMutableArray alloc]init];
          [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:productArray];
        
        
        for (NSDictionary *myDict in productArray)
        {
            [pastDataArray addObject:[myDict objectForKey:@"inventory_item_no"]];
            [pastDataArray addObject:[myDict objectForKey:@"inventary_item_name"]];
            
            
        }
      NSString *querySQL5 = [NSString stringWithFormat: @"SELECT print_id FROM printer"];
       NSMutableArray *printerArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL5 resultsArray:printerArray];
    
        if ([printerArray count]>0)
        {
            for (NSDictionary *Dict in printerArray)
            {
                [PrinterslistArray addObject:[Dict objectForKey:@"print_id"]];
            }
        }

    NSMutableArray *taxnamesArray,*taxratesArray;
    taxnamesArray=[[NSMutableArray alloc]init];
    taxratesArray=[[NSMutableArray alloc]init];
    
    NSString *querySQL2 = [NSString stringWithFormat:@"SELECT name,tax_value FROM taxes"];
    NSMutableArray *taxesArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL2 resultsArray:taxesArray];
    
    if ([taxesArray count]>0){
        for (NSDictionary *myDict in taxesArray)
        {
            
            [taxnamesArray addObject:[myDict objectForKey:@"name"]];
            [taxratesArray addObject:[myDict objectForKey:@"tax_value"]];
            
            
        }
        if ([taxnamesArray count]>0){
            
            tax1Name=[taxnamesArray objectAtIndex:0];
            tax1Rate=[taxratesArray objectAtIndex:0];
            
        }
        if ([taxnamesArray count]>1){
            
            tax2Name=[taxnamesArray objectAtIndex:1];
            tax2Rate=[taxratesArray objectAtIndex:1];
        }
        if ([taxnamesArray count]>2){
            tax3Name=[taxnamesArray objectAtIndex:2];
            tax3Rate=[taxratesArray objectAtIndex:2];
            
        }
        
    }
    
    [self productbtnclicked];
    [super viewWillAppear:YES];
}
- (IBAction)modifierItem_deleteButtonClicked:(id)sender{
    UIButton *but =sender;
    NSInteger selected=but.tag-1;
    [ModifierItemNosArray removeObjectAtIndex:selected];
    [modifierItemsTable reloadData];
}
- (IBAction)orderingInfo_editButtonClicked:(id)sender{
    UIButton *but =sender;
    selectedOrder=but.tag-1;
    VendorpartStr=[VendorPartsArray objectAtIndex:selectedOrder];
    CostperStr=[CostpersArray objectAtIndex:selectedOrder];
    CaseCostStr=[CasecostsArray objectAtIndex:selectedOrder];
    Numberincasestr=[NumberincasesArray objectAtIndex:selectedOrder];
    PreferredStr=[preferredsArray objectAtIndex:selectedOrder];
    selectedorderinfo=YES;
    [self AddvendorDetailsView];
}
- (IBAction)orderingInfo_deleteButtonClicked:(id)sender
{
    UIButton *but =sender;
    // //NSLog(@"EditButton %d",but.tag);
    
    NSInteger selected=but.tag-1;
    
    [SelectedOpVendorsArray removeObjectAtIndex:selected];
    
    [VendorPartsArray removeObjectAtIndex:selected];
    [CostpersArray removeObjectAtIndex:selected];
    [CasecostsArray removeObjectAtIndex:selected];
    [NumberincasesArray removeObjectAtIndex:selected];
    [preferredsArray removeObjectAtIndex:selected];
    
    [OrderingInfoTable reloadData];
    
}
-(void)editVendorViewRemove
{
    NSArray * depertmentViewArray = EditvendorScrollView.subviews;
    for (int i = 0; i<[depertmentViewArray count]; i++) {
        UIView *vi =[depertmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addDepartmentViewArray = EditVendorPopup.subviews;
    for (int i = 0; i<[addDepartmentViewArray count]; i++) {
        UIView *vi =[addDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditvendorScrollView removeFromSuperview],[EditVendorPopup removeFromSuperview];
    
}
#pragma mark -
#pragma mark - Edit,Delete Views methd
- (IBAction)vendor_editButtonClicked:(id)sender
{
    UIButton *but =sender;
    // //NSLog(@"EditButton %d",but.tag);
    
    NSInteger  selectedrow=but.tag-1;
    if (!EditVendorPopup)
    EditVendorPopup=[[UIView alloc]init];
    if (isLandScope) {
        EditVendorPopup.frame=CGRectMake(0, 0, 1024, 768);
    }else{
        
        EditVendorPopup.frame=CGRectMake(0, 0, 768, 1024);
    }
    [EditVendorPopup setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:EditVendorPopup];
    
    NSString *Termstr=[termsArray objectAtIndex:selectedrow];
    NSString *selectedid=[VendornumbersArray objectAtIndex:selectedrow];
    vendorNumber=selectedid;
    NSString *minimum=[minimumorderArray objectAtIndex:selectedrow];
    NSString *commissionstr=[commissionsArray objectAtIndex:selectedrow];
    NSString *companynamestr=[companyNAmesArray objectAtIndex:selectedrow];
    NSString *flat=[flatrentsArray objectAtIndex:selectedrow];
    NSString *taxStr=[TaxidsArray objectAtIndex:selectedrow];
    NSString *billable=[billablesArray objectAtIndex:selectedrow];
    NSString *social=[socialsArray objectAtIndex:selectedrow];
    NSString *postr=[podeliverysArray objectAtIndex:selectedrow];
    NSArray *aaray=[[NSArray alloc]initWithObjects:selectedid,Termstr,minimum,commissionstr,companynamestr,flat,taxStr,billable,social,@"", nil];
    // //NSLog(@"%@",postr);
    // //NSLog(@"%@",podeliverysArray);
    NSString *streetstr=[streetaddressArray objectAtIndex:selectedrow];
    NSString *extended=[exteddedArray objectAtIndex:selectedrow];
    NSString *citystr=[citysArray objectAtIndex:selectedrow];
    NSString *statestr=[statesArray objectAtIndex:selectedrow];
    NSString *zipcodestr=[ZipcodesArray objectAtIndex:selectedrow];
    NSString *countrystr=[countrysArray objectAtIndex:selectedrow];
    NSString *fisrtnamestr=[firstnamesArray objectAtIndex:selectedrow];
    NSString *lastnamestr=[lastnamesArray objectAtIndex:selectedrow];
    NSString *phnumberstr=[phnumbersArray objectAtIndex:selectedrow];
    NSString *faxstr=[faxesArray objectAtIndex:selectedrow];
    NSString *emailstr=[emailsArray objectAtIndex:selectedrow];
    NSString *websitestr=[websitesArray objectAtIndex:selectedrow];
    NSArray *addresssArray=[[NSArray alloc]initWithObjects:streetstr,extended,citystr,statestr,zipcodestr,countrystr,fisrtnamestr,lastnamestr,phnumberstr,faxstr,emailstr,websitestr, nil];
    // //NSLog(@"%@",addresssArray);
    ChangevendorNO=selectedid;
    ChangeTerms=Termstr;
    ChangeminimumOrder=minimum;
    Changecommission=commissionstr;
    ChangeFlatRent=flat;
    ChangeCompanyname=companynamestr;
    ChangeTaxtID=taxStr;
    Changestate=statestr;
    ChangeBillable=billable;
    ChangeSocialsecurity=social;
    ChangeZipcode=zipcodestr;
    ChangestreetAddress=streetstr;
    ChangeExtendedAddress=extended;
    ChangeCity=citystr;
    Changecountry=countrystr;
    Changefirstname=fisrtnamestr;
    Changelastname=lastnamestr;
    ChangephNUmber=phnumberstr;
    Changefaxnumber=faxstr;
    Changeemail=emailstr;
    Changewebsite=websitestr;
    
  
    
     if (!EditvendorScrollView)
    EditvendorScrollView=[[UIScrollView alloc]init];
    EditvendorScrollView.frame=CGRectMake(20, 40, EditVendorPopup.frame.size.width-40, EditVendorPopup.frame.size.height-80);
    [EditvendorScrollView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    [EditvendorScrollView.layer setBorderWidth:2.0];
    [EditvendorScrollView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
    EditvendorScrollView.contentSize=CGSizeMake(EditVendorPopup.frame.size.width-40, EditVendorPopup.frame.size.height-20+300);
    //AddvendorsView.layer.cornerRadius=8;
    [EditVendorPopup addSubview:EditvendorScrollView];
    
    CGFloat fieldwidth2=(EditvendorScrollView.frame.size.width-20)/4;
    CGFloat a=(fieldwidth2/2);
     if (!chnageInfotextLbl)
    chnageInfotextLbl=[[UILabel alloc]init];
    chnageInfotextLbl.frame=CGRectMake(a,10 ,350, 30);
    [chnageInfotextLbl setText:@"General Information"];
    [chnageInfotextLbl setFont:[UIFont systemFontOfSize:20.0f]];
    [chnageInfotextLbl setBackgroundColor:[UIColor clearColor]];
    [chnageInfotextLbl setTextColor:[UIColor whiteColor]];
    [EditvendorScrollView addSubview:chnageInfotextLbl];
      if (!chnageAddresstextLbl)
    chnageAddresstextLbl=[[UILabel alloc]init];
    chnageAddresstextLbl.frame=CGRectMake(a+chnageInfotextLbl.frame.size.width+40,10 ,350, 30);
    [chnageAddresstextLbl setText:@"Address"];
    [chnageAddresstextLbl setFont:[UIFont systemFontOfSize:20.0f]];
    [chnageAddresstextLbl setBackgroundColor:[UIColor clearColor]];
    [chnageAddresstextLbl setTextColor:[UIColor whiteColor]];
    [EditvendorScrollView addSubview:chnageAddresstextLbl];
    int f=50;
    
    for (int i=0; i<9; i++)
    {
        chnagegeneralinfolbl=[[UILabel alloc] init];
        chnagegeneralinfolbl.frame=CGRectMake(a-80, f,fieldwidth2+10, 40);
        
        chnagegeneralinfolbl.tag=i+100;
        [chnagegeneralinfolbl setFont:[UIFont systemFontOfSize:20.0f]];
        [chnagegeneralinfolbl setBackgroundColor:[UIColor clearColor]];
        [chnagegeneralinfolbl setTextColor:[UIColor whiteColor]];
        NSArray *labelArray;
        if (!labelArray)
        labelArray=[[NSArray alloc] initWithObjects:@"Vendor Number",@"Terms ",@"Minimum Order",@"Commission %",@"Company Name",@"Flat Rent Rate",@"Tax Id ",@"BillableDepartment",@"SocialSecurity",nil];
        [chnagegeneralinfolbl setText:[labelArray objectAtIndex:i]];
        [chnagegeneralinfolbl setTextAlignment:NSTextAlignmentLeft];
        [EditvendorScrollView addSubview:chnagegeneralinfolbl];
        //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
        
        chnageGeneralinfoField=[[UITextField alloc] init];
        //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
        chnageGeneralinfoField.frame=CGRectMake(fieldwidth2+5, f,fieldwidth2-10, 40);
        chnageGeneralinfoField.delegate=self;
        chnageGeneralinfoField.tag=i+100;
        
        UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
        // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
        chnageGeneralinfoField.leftView = paddingview;
        [paddingview removeFromSuperview],paddingview=nil;
        chnageGeneralinfoField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
        chnageGeneralinfoField.leftViewMode = UITextFieldViewModeAlways;
        //[chnageGeneralinfoField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
        [chnageGeneralinfoField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
        [chnageGeneralinfoField addTarget:self action:@selector(ChangeGeneralinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
        [chnageGeneralinfoField setText:[aaray objectAtIndex:i]];
        [chnageGeneralinfoField setAutocorrectionType:UITextAutocorrectionTypeNo];
        
        [EditvendorScrollView addSubview:chnageGeneralinfoField];
        
        f=f+60;
        
    }
     if (!changepolbl)
    changepolbl=[[UILabel alloc] init];
    changepolbl.frame=CGRectMake(a-80, 580,fieldwidth2+10, 40);
    [changepolbl setFont:[UIFont systemFontOfSize:20.0f]];
    [changepolbl setBackgroundColor:[UIColor clearColor]];
    [changepolbl setTextColor:[UIColor whiteColor]];
    [changepolbl setText:@"PoDeliveryMethod"];
    [changepolbl setTextAlignment:NSTextAlignmentLeft];
    [EditvendorScrollView addSubview:changepolbl];
     if (!changeDeliverymethodBtn)
    changeDeliverymethodBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    changeDeliverymethodBtn.frame=CGRectMake(fieldwidth2+5, 580, fieldwidth2-10, 40);
    [changeDeliverymethodBtn addTarget:self action:@selector(changeDeliveryMethodbtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [changeDeliverymethodBtn setTitle:postr forState:UIControlStateNormal];
    [changeDeliverymethodBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[changeDeliverymethodBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [changeDeliverymethodBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [EditvendorScrollView addSubview:changeDeliverymethodBtn];
      if (!changeDeliveryTypesTable)
    changeDeliveryTypesTable = [[UITableView alloc] initWithFrame:CGRectMake(fieldwidth2+5, 620,fieldwidth2-10,100) style:UITableViewStylePlain];
    changeDeliveryTypesTable.backgroundColor=[UIColor whiteColor];
    changeDeliveryTypesTable.delegate = self;
    changeDeliveryTypesTable.dataSource = self;
    changeDeliveryTypesTable.scrollEnabled = YES;
    changeDeliveryTypesTable.hidden=YES;
    [changeDeliveryTypesTable.layer setBorderWidth: 1.0];
    [changeDeliveryTypesTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditvendorScrollView addSubview:changeDeliveryTypesTable];
     if (!DeliverymethodsArray)
    DeliverymethodsArray=[[NSArray alloc]initWithObjects:@"Print",@"Fax",@"Email", nil];
    int g=40;
    for (int i=0; i<12; i++)
    {
       
        changeAddresslbl=[[UILabel alloc] init];
        changeAddresslbl.frame=CGRectMake(fieldwidth2+chnageGeneralinfoField.frame.size.width+15, g,fieldwidth2+10, 40);
        changeAddresslbl.tag=i+100;
        [changeAddresslbl setFont:[UIFont systemFontOfSize:20.0f]];
        [changeAddresslbl setBackgroundColor:[UIColor clearColor]];
        [changeAddresslbl setTextColor:[UIColor whiteColor]];
        NSArray *labelArray;
        if (!labelArray)
        labelArray=[[NSArray alloc] initWithObjects:@"Street Address",@"Extended Address ",@"City",@"State",@"Zip Code",@"Country",@"First Name",@"Last Name",@"PhoneNumber",@"Fax Number",@"Email",@"Website",nil];
        [changeAddresslbl setText:[labelArray objectAtIndex:i]];
        [changeAddresslbl setTextAlignment:NSTextAlignmentLeft];
        [EditvendorScrollView addSubview:changeAddresslbl];
        //// //NSLog(@"%f",Addresslbl.frame.origin.y);
        
        chnageAddressField=[[UITextField alloc] init];
        //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
        chnageAddressField.frame=CGRectMake(fieldwidth2+chnageGeneralinfoField.frame.size.width+10+changeAddresslbl.frame.size.width+5, g,fieldwidth2-10, 40);
        [chnageAddressField addTarget:self action:@selector(ChangeAddressFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
        chnageAddressField.delegate=self;
        chnageAddressField.tag=i+100;
        UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
        // // //NSLog(@"%f",AddressField.frame.origin.y);
        [chnageAddressField setText:[addresssArray objectAtIndex:i]];
        chnageAddressField.leftView = paddingview;
        [paddingview removeFromSuperview],paddingview=nil;
        chnageAddressField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
        chnageAddressField.leftViewMode = UITextFieldViewModeAlways;
        //[chnageAddressField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
        [chnageAddressField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
        [chnageAddressField setAutocorrectionType:UITextAutocorrectionTypeNo];
        [EditvendorScrollView addSubview:chnageAddressField];
        
        g=g+60;
        
    }
    
    @autoreleasepool {
        changeSaveVendorsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        changeSaveVendorsBtn.frame=CGRectMake(fieldwidth2+80, 800, 80, 30);
        [changeSaveVendorsBtn addTarget:self action:@selector(SaveChnageVendorData) forControlEvents:UIControlEventTouchUpInside];
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [changeSaveVendorsBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[changeSaveVendorsBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [changeSaveVendorsBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        [EditvendorScrollView addSubview:changeSaveVendorsBtn];
        
        changeCancelVendorBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
       changeCancelVendorBtn.frame=CGRectMake(fieldwidth2+220, 800, 80, 30);
        [changeCancelVendorBtn addTarget:self action:@selector(CancelChangeVendorData) forControlEvents:UIControlEventTouchUpInside];
        [changeCancelVendorBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        // [changeCancelVendorBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        [changeCancelVendorBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [EditvendorScrollView addSubview:changeCancelVendorBtn];
    }
    addresssArray=nil,addresssArray=nil;
    Termstr=nil,selectedid=nil,minimum=nil,commissionstr=nil;
    companynamestr=nil ;
    flat=nil;
    taxStr=nil ;
    billable=nil;
    social=nil;
    postr=nil;
    streetstr=nil ;
    extended=nil;
    citystr=nil;
    statestr=nil;
    zipcodestr=nil;
    countrystr=nil;
    fisrtnamestr=nil;
    lastnamestr=nil;
    phnumberstr=nil;
    faxstr=nil;
    emailstr=nil;
    websitestr=nil;
}

- (IBAction)vendor_deleteButtonClicked:(id)sender{
    UIButton *but =sender;
    // //NSLog(@"EditButton %d",but.tag);
    selectedVendor=but.tag-1;
    deletevendorAlert=[[UIAlertView alloc]initWithTitle:@"Delete" message:@"Are you sure you want delete the Vendor" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel", nil];
    [deletevendorAlert show];
}
-(void)editProductViewremoveMethod
{
    NSArray * depertmentViewArray = EditProductView.subviews;
    for (int i = 0; i<[depertmentViewArray count]; i++) {
        UIView *vi =[depertmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addDepartmentViewArray = EditproductPopUpView.subviews;
    for (int i = 0; i<[addDepartmentViewArray count]; i++) {
        UIView *vi =[addDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditProductView removeFromSuperview],[EditproductPopUpView removeFromSuperview];
}
- (IBAction)product_editButtonClicked:(id)sender
{
    EditmodifierItem=@"no";
    EditCountthisItem=@"no";
    Editallowbuyback=@"no";
    Editprintonreceipt=@"no";
    Editfoodstampable=@"no";
    Editpromptprice=@"no";

    UIButton *but =sender;
    // //NSLog(@"EditButton %d",but.tag);
    
    NSInteger  selectedrow=but.tag-1;
    if (!EditproductPopUpView)
    EditproductPopUpView=[[UIView alloc]init];
    if (isLandScope) {
        EditproductPopUpView.frame=CGRectMake(0, 0, 1024, 768);
    }else{
        
        EditproductPopUpView.frame=CGRectMake(0, 0, 768, 1024);
    }
    [EditproductPopUpView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:EditproductPopUpView];
     if (!EditProductView)
    EditProductView=[[UIScrollView alloc]init];
    if (isLandScope){
        EditProductView.frame=CGRectMake(20, 40, EditproductPopUpView.frame.size.width-40, EditproductPopUpView.frame.size.height-80);
    }else{
        EditProductView.frame=CGRectMake(20, 150, EditproductPopUpView.frame.size.width-40, EditproductPopUpView.frame.size.height-400);
    }
    [EditProductView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    EditProductView.contentSize=CGSizeMake(EditproductPopUpView.frame.size.width-40, EditproductPopUpView.frame.size.height-20+300);
    [EditProductView.layer setBorderWidth:2.0];
    [EditProductView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
    //AddvendorsView.layer.cornerRadius=8;
    [EditproductPopUpView addSubview:EditProductView];
    
    NSString *Deptstr=[ProductDepartmentsArray objectAtIndex:selectedrow];
    NSString *itemnumber=[ItemNumbersArray objectAtIndex:selectedrow];
    NSString *itemname=[ItemnameArray objectAtIndex:selectedrow];
    NSString *des=[productDesArray objectAtIndex:selectedrow];
    NSString *cost=[CostArray objectAtIndex:selectedrow];
    NSString *priceyoucharge=[priceyouchargeArray objectAtIndex:selectedrow];
    NSString *pricewithtax=[pricewithTaxArray objectAtIndex:selectedrow];
    NSString *instock=[InstockArray objectAtIndex:selectedrow];
    NSString *vendorno=[productVendorsArray objectAtIndex:selectedrow];
    NSString *taxstr=[taxvaluesArray objectAtIndex:selectedrow];
    InvItemNumber=itemnumber;
    
   
   
  
    EditProductNotes=[productNotesArray objectAtIndex:selectedrow];
    
     NSString *querySQL = [NSString stringWithFormat: @"SELECT inventary_modifier_item,inventary_count_this_item,inventary_prompt_quantity,inventary_print_on_receipt,inventary_foodstampable,inventary_prompt_price,bonus_points,barcodes,location,unit_size,unit_type,commission_optional_info FROM optional_info_table WHERE inventory_item_no='%@'",itemnumber];
    NSMutableArray *optionalinfoArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:optionalinfoArray];
    
    @autoreleasepool {
        for (NSDictionary *myDict in optionalinfoArray)
        {
            EditmodifierItem=[myDict objectForKey:@"inventary_modifier_item"];
            EditCountthisItem=[myDict objectForKey:@"inventary_count_this_item"];
            Editallowbuyback=[myDict objectForKey:@"inventary_prompt_quantity"];
            Editprintonreceipt=[myDict objectForKey:@"inventary_print_on_receipt"];
            Editfoodstampable=[myDict objectForKey:@"inventary_foodstampable"];
            Editpromptprice=[myDict objectForKey:@"inventary_prompt_price"];
            
            Editbonuspoint=[myDict objectForKey:@"bonus_points"];
            
            Editbarcode=[myDict objectForKey:@"barcodes"];
            Editlocation=[myDict objectForKey:@"location"];
            Editunitsize=[myDict objectForKey:@"unit_size"];
            EditUnittype=[myDict objectForKey:@"unit_type"];
            Editcommission=[myDict objectForKey:@"commission_optional_info"];
        }

    }
    
     NSString *skuquerySQL = [NSString stringWithFormat: @"SELECT alternate_sku_value FROM alternate_sku WHERE inventory_item_no='%@'",itemnumber];
    NSMutableArray *skusArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:skuquerySQL resultsArray:skusArray];
    
   
    SkusArray=[[NSMutableArray alloc]init];
    SelectedSkusArray=[[NSMutableArray alloc]init];
        
    for (NSDictionary *myDict in skusArray)
    {
        [SelectedSkusArray addObject:[myDict objectForKey:@"alternate_sku_value"]];
    }
    
      NSString *modquerySQL = [NSString stringWithFormat: @"SELECT modifier_item_no,inventary_item_name FROM modifier_table WHERE inventory_item_no='%@'",itemnumber];
    NSMutableArray *modsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:modquerySQL resultsArray:modsArray];
    
    
        ModifierItemNosArray=[[NSMutableArray alloc]init];
        selectedModifiers=[[NSMutableArray alloc]init];
        modifierNamesArray=[[NSMutableArray alloc]init];
        SelectedNamesArray=[[NSMutableArray alloc]init];
          @autoreleasepool {
        for (NSDictionary *myDict in modsArray)
        {
            [selectedModifiers addObject:[myDict objectForKey:@"modifier_item_no"]];
            [SelectedNamesArray addObject:[myDict objectForKey:@"inventary_item_name"]];
            
        }
        }
    
  
    NSString *orderquerySQL = [NSString stringWithFormat: @"SELECT vendor_company_name,venderpart_no,cost_per,case_cost,no_in_case,preferred FROM ordering_info_table WHERE inventory_item_no='%@'",itemnumber];
    NSMutableArray *orderinfosArray=[[NSMutableArray alloc]init];
    
    [[DataBaseManager dataBaseManager]execute:orderquerySQL resultsArray:orderinfosArray];
  
        SelectedOpVendorsArray=[[NSMutableArray alloc] init];
        VendorPartsArray=[[NSMutableArray alloc] init];
        CostpersArray=[[NSMutableArray alloc] init];
        CasecostsArray=[[NSMutableArray alloc] init];
        NumberincasesArray=[[NSMutableArray alloc] init];
        preferredsArray=[[NSMutableArray alloc] init];
       
        @autoreleasepool {
            for (NSDictionary *myDict in orderinfosArray)
            {
                [SelectedOpVendorsArray addObject:[myDict objectForKey:@"vendor_company_name"]];
                [VendorPartsArray addObject:[myDict objectForKey:@"venderpart_no"]];
                [CostpersArray addObject:[myDict objectForKey:@"cost_per"]];
                [CasecostsArray addObject:[myDict objectForKey:@"case_cost"]];
                [NumberincasesArray addObject:[myDict objectForKey:@"no_in_case"]];
                [preferredsArray addObject:[myDict objectForKey:@"preferred"]];
                
            }
        }
   
    NSArray *array=[taxstr componentsSeparatedByString:@","];
    NSString *tax1value,*tax2value,*tax3value,*bartaxvalue;
    for (int i=0; i<[array count]; i++)
    {
        NSString  *tvalue=[array objectAtIndex:i];
        if ([tvalue isEqualToString:tax1Name])
        {
            tax1value=tvalue;
        }
        if ([tvalue isEqualToString:tax2Name])
        {
            tax2value=tvalue;
        }
        if ([tvalue isEqualToString:tax3Name])
        {
            tax3value=tvalue;
        }
        if ([tvalue isEqualToString:@"Bartax"])
        {
            bartaxvalue=tvalue;
        }
        
        
    }
    array=nil;
   
      NSString *querySQL7 = [NSString stringWithFormat:@"SELECT department_id FROM department_details"];
    NSMutableArray *deptsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:deptsArray];
    
    DepartmentNamesArray=[[NSMutableArray alloc]init];
    @autoreleasepool {
        for (NSDictionary *myDict in deptsArray)
        {
            NSString *catname=[myDict objectForKey:@"department_id"];
            [DepartmentNamesArray addObject:catname];
            catname=nil;
        }
    }
   
    CGFloat changeProductfieldwidth=(EditProductView.frame.size.width-100)/4;
    CGFloat edit=(changeProductfieldwidth/2)+20;
     if (!ChangeDepartmentlbl)
    ChangeDepartmentlbl=[[UILabel alloc] init];
    ChangeDepartmentlbl.frame=CGRectMake(edit-80, 30,changeProductfieldwidth, 50);
    [ChangeDepartmentlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [ChangeDepartmentlbl setBackgroundColor:[UIColor clearColor]];
    [ChangeDepartmentlbl setTextColor:[UIColor whiteColor]];
    [ChangeDepartmentlbl setText:@"Department for this Item"];
    ChangeDepartmentlbl.lineBreakMode = NSLineBreakByWordWrapping;
    ChangeDepartmentlbl.numberOfLines = 2;
    [ChangeDepartmentlbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductView addSubview:ChangeDepartmentlbl];
    
   
    ChangeDepartmentBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    ChangeDepartmentBtn.frame=CGRectMake(changeProductfieldwidth+5, 30, changeProductfieldwidth-10, 40);
    [ChangeDepartmentBtn addTarget:self action:@selector(DepartmentChangeBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [ChangeDepartmentBtn setTitle:Deptstr forState:UIControlStateNormal];
    [ChangeDepartmentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[ChangeDepartmentBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [ChangeDepartmentBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [EditProductView addSubview:ChangeDepartmentBtn];
     if (!ChangeDepartmentsTable)
    ChangeDepartmentsTable = [[UITableView alloc] initWithFrame:CGRectMake(changeProductfieldwidth+5, 70, changeProductfieldwidth-10, 100) style:UITableViewStylePlain];
    ChangeDepartmentsTable.backgroundColor=[UIColor whiteColor];
    ChangeDepartmentsTable.delegate = self;
    ChangeDepartmentsTable.dataSource = self;
    ChangeDepartmentsTable.scrollEnabled = YES;
    ChangeDepartmentsTable.hidden=YES;
    [ChangeDepartmentsTable.layer setBorderWidth: 1.0];
    [ChangeDepartmentsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditProductView addSubview:ChangeDepartmentsTable];
     if (!ChangeItemNumberlbl)
    ChangeItemNumberlbl=[[UILabel alloc] init];
    ChangeItemNumberlbl.frame=CGRectMake(edit-80, 90,changeProductfieldwidth, 40);
    [ChangeItemNumberlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [ChangeItemNumberlbl setBackgroundColor:[UIColor clearColor]];
    [ChangeItemNumberlbl setTextColor:[UIColor whiteColor]];
    [ChangeItemNumberlbl setText:@"Item Number"];
    [ChangeItemNumberlbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductView addSubview:ChangeItemNumberlbl];
      if (!ChangeItemNumberField)
    ChangeItemNumberField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    ChangeItemNumberField.frame=CGRectMake(changeProductfieldwidth+5, 90,changeProductfieldwidth-10, 40);
    ChangeItemNumberField.delegate=self;
    ChangeItemNumberField.text=itemnumber;
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    ChangeItemNumberField.leftView = paddingview;
    ChangeItemNumberField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    ChangeItemNumberField.leftViewMode = UITextFieldViewModeAlways;
    //[ChangeItemNumberField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [ChangeItemNumberField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [ChangeItemNumberField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditProductView addSubview:ChangeItemNumberField];
     if (!ChangeItemNamelbl)
    ChangeItemNamelbl=[[UILabel alloc] init];
    ChangeItemNamelbl.frame=CGRectMake(edit-80, 150,changeProductfieldwidth, 40);
    [ChangeItemNamelbl setFont:[UIFont systemFontOfSize:20.0f]];
    [ChangeItemNamelbl setBackgroundColor:[UIColor clearColor]];
    [ChangeItemNamelbl setTextColor:[UIColor whiteColor]];
    [ChangeItemNamelbl setText:@"Item Name"];
    [ChangeItemNamelbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductView addSubview:ChangeItemNamelbl];
      if (!ChangeItemNameField)
    ChangeItemNameField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    ChangeItemNameField.frame=CGRectMake(changeProductfieldwidth+5, 150,changeProductfieldwidth-10, 40);
    ChangeItemNameField.delegate=self;
    UIView *paddingview2=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    ChangeItemNameField.leftView = paddingview2;
    ChangeItemNameField.text=itemname;
    ChangeItemNameField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    ChangeItemNameField.leftViewMode = UITextFieldViewModeAlways;
    //[ChangeItemNameField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [ChangeItemNameField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [ChangeItemNameField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditProductView addSubview:ChangeItemNameField];
      if (!ChangeDescroptionlbl)
    ChangeDescroptionlbl=[[UILabel alloc] init];
    ChangeDescroptionlbl.frame=CGRectMake(edit-80, 210,changeProductfieldwidth+10, 40);
    [ChangeDescroptionlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [ChangeDescroptionlbl setBackgroundColor:[UIColor clearColor]];
    [ChangeDescroptionlbl setTextColor:[UIColor whiteColor]];
    [ChangeDescroptionlbl setText:@"2nd Description"];
    [ChangeDescroptionlbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductView addSubview:ChangeDescroptionlbl];
     if (!ChangeDescriptionText)
    ChangeDescriptionText=[[UITextView alloc] init];
    ChangeDescriptionText.frame=CGRectMake(changeProductfieldwidth+5, 200,changeProductfieldwidth-10,80);
    ChangeDescriptionText.delegate=self;
    ChangeDescriptionText.font=[UIFont systemFontOfSize:14.0f];
    ChangeDescriptionText.text=des;
    [ChangeDescriptionText setAutocorrectionType:UITextAutocorrectionTypeNo];
    ChangeDescriptionText.layer.cornerRadius=8;
    [EditProductView addSubview:ChangeDescriptionText];
    if (!ChangeCostlbl)
    ChangeCostlbl=[[UILabel alloc] init];
    ChangeCostlbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+15, 30,changeProductfieldwidth+10, 40);
    [ChangeCostlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [ChangeCostlbl setBackgroundColor:[UIColor clearColor]];
    [ChangeCostlbl setTextColor:[UIColor whiteColor]];
    
    [ChangeCostlbl setText:@"Cost"];
    [ChangeCostlbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductView addSubview:ChangeCostlbl];
     if (!ChangeCostField)
    ChangeCostField=[[UITextField alloc] init];
    ChangeCostField.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5, 30,changeProductfieldwidth-10, 40);
    [ChangeCostField addTarget:self action:@selector(AddressFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
    ChangeCostField.delegate=self;
    UIView *paddingview3=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    ChangeCostField.leftView = paddingview3;
    ChangeCostField.text=cost;
    ChangeCostField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    ChangeCostField.leftViewMode = UITextFieldViewModeAlways;
    //[ChangeCostField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [ChangeCostField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [ChangeCostField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditProductView addSubview:ChangeCostField];
      if (!ChangepriceyouChargelbl)
    ChangepriceyouChargelbl=[[UILabel alloc] init];
    ChangepriceyouChargelbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+15,90,changeProductfieldwidth+10, 40);
    [ChangepriceyouChargelbl setFont:[UIFont systemFontOfSize:20.0f]];
    [ChangepriceyouChargelbl setBackgroundColor:[UIColor clearColor]];
    [ChangepriceyouChargelbl setTextColor:[UIColor whiteColor]];
    
    [ChangepriceyouChargelbl setText:@"Price You Charge"];
    [ChangepriceyouChargelbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductView addSubview:ChangepriceyouChargelbl];
      if (!ChangePriceyouChargeField)
    ChangePriceyouChargeField=[[UITextField alloc] init];
    ChangePriceyouChargeField.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5,90,changeProductfieldwidth-10, 40);
    [ChangePriceyouChargeField addTarget:self action:@selector(PriceYouChargeClicked:) forControlEvents:UIControlEventEditingDidEnd];
    ChangePriceyouChargeField.delegate=self;
    UIView *paddingview4=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    ChangePriceyouChargeField.leftView = paddingview4;
    ChangePriceyouChargeField.text=priceyoucharge;
    ChangePriceyouChargeField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    ChangePriceyouChargeField.leftViewMode = UITextFieldViewModeAlways;
    //[ChangePriceyouChargeField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [ChangePriceyouChargeField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [ChangePriceyouChargeField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditProductView addSubview:ChangePriceyouChargeField];
     if (!ChangepriceWithTaxlbl)
    ChangepriceWithTaxlbl=[[UILabel alloc] init];
    ChangepriceWithTaxlbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+15,150,changeProductfieldwidth+10, 40);
    [ChangepriceWithTaxlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [ChangepriceWithTaxlbl setBackgroundColor:[UIColor clearColor]];
    [ChangepriceWithTaxlbl setTextColor:[UIColor whiteColor]];
    
    [ChangepriceWithTaxlbl setText:@"Price with Tax"];
    [ChangepriceWithTaxlbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductView addSubview:ChangepriceWithTaxlbl];
    
    ChangePriceWithTaxBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    ChangePriceWithTaxBtn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5,150,changeProductfieldwidth-10, 40);
    [ChangePriceWithTaxBtn addTarget:self action:@selector(ChangepricewithTaxClicked) forControlEvents:UIControlEventTouchUpInside];
    [ChangePriceWithTaxBtn setTitle:pricewithtax forState:UIControlStateNormal];
    [ChangePriceWithTaxBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[ChangePriceWithTaxBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
    [ChangePriceWithTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]] forState:UIControlStateNormal];
    [EditProductView addSubview:ChangePriceWithTaxBtn];
     if (!ChangeInStocklbl)
    ChangeInStocklbl=[[UILabel alloc] init];
    ChangeInStocklbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+15,210,changeProductfieldwidth+10, 40);
    [ChangeInStocklbl setFont:[UIFont systemFontOfSize:20.0f]];
    [ChangeInStocklbl setBackgroundColor:[UIColor clearColor]];
    [ChangeInStocklbl setTextColor:[UIColor whiteColor]];
    
    [ChangeInStocklbl setText:@"In Stock"];
    [ChangeInStocklbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductView addSubview:ChangeInStocklbl];
      if (!ChangeInStockField)
    ChangeInStockField=[[UITextField alloc] init];
    ChangeInStockField.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5,210,changeProductfieldwidth-10, 40);
    [ChangeInStockField addTarget:self action:@selector(AddressFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
    ChangeInStockField.delegate=self;
    UIView *paddingview5=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    ChangeInStockField.leftView = paddingview5;
    ChangeInStockField.text=instock;
    ChangeInStockField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    ChangeInStockField.leftViewMode = UITextFieldViewModeAlways;
    //[ChangeInStockField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [ChangeInStockField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [ChangeInStockField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditProductView addSubview:ChangeInStockField];
     if (!ChangeAddpricinglbl)
    ChangeAddpricinglbl=[[UILabel alloc] init];
    ChangeAddpricinglbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+15,270,changeProductfieldwidth+10, 50);
    [ChangeAddpricinglbl setFont:[UIFont systemFontOfSize:20.0f]];
    [ChangeAddpricinglbl setBackgroundColor:[UIColor clearColor]];
    [ChangeAddpricinglbl setTextColor:[UIColor whiteColor]];
    
    [ChangeAddpricinglbl setText:@"Addpricing from a Vendor"];
    ChangeAddpricinglbl.lineBreakMode = NSLineBreakByWordWrapping;
    ChangeAddpricinglbl.numberOfLines = 2;
    [ChangeAddpricinglbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductView addSubview:ChangeAddpricinglbl];
   
    VendornumbersArray=[[NSMutableArray alloc]init];
      NSString *vendorquerySQL = [NSString stringWithFormat: @"SELECT vendor_no FROM vendor"];
    NSMutableArray *vendorsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:vendorquerySQL resultsArray:vendorsArray];
    
    for (NSDictionary *myDict in vendorsArray)
    {
        NSString *vendorno=[myDict objectForKey:@"vendor_no"];
        
        [VendornumbersArray addObject:vendorno];
        vendorno=nil;
    }
    ChangeAddpricingBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    ChangeAddpricingBtn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5,270,changeProductfieldwidth-10, 40);
    [ChangeAddpricingBtn addTarget:self action:@selector(ChangeAddpricingClicked) forControlEvents:UIControlEventTouchUpInside];
    [ChangeAddpricingBtn setTitle:vendorno forState:UIControlStateNormal];
    [ChangeAddpricingBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[ChangeAddpricingBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [ChangeAddpricingBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [EditProductView addSubview:ChangeAddpricingBtn];
    
      if (!ChangeVendorsTable)
    ChangeVendorsTable = [[UITableView alloc] initWithFrame:CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5,170,changeProductfieldwidth-10, 100) style:UITableViewStylePlain];
    ChangeVendorsTable.backgroundColor=[UIColor whiteColor];
    ChangeVendorsTable.delegate = self;
    ChangeVendorsTable.dataSource = self;
    ChangeVendorsTable.scrollEnabled = YES;
    ChangeVendorsTable.hidden=YES;
    [ChangeVendorsTable.layer setBorderWidth: 1.0];
    [ChangeVendorsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditProductView addSubview:ChangeVendorsTable];
    
    Changetax1Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    Changetax1Btn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+10,35,30, 30);
    [Changetax1Btn addTarget:self action:@selector(ChangeTax1Clicked) forControlEvents:UIControlEventTouchUpInside];
    [Changetax1Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[Changetax1Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    // [Changetax1Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    
    [Changetax1Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [Changetax1Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    [EditProductView addSubview:Changetax1Btn];
     if (!Changetax1lbl)
    Changetax1lbl=[[UILabel alloc] init];
    Changetax1lbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+45,30,50, 40);
    [Changetax1lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Changetax1lbl setBackgroundColor:[UIColor clearColor]];
    [Changetax1lbl setTextColor:[UIColor whiteColor]];
    //tax1Btn.selected=YES;
    [Changetax1lbl setText:tax1Name];
    [Changetax1lbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductView addSubview:Changetax1lbl];
    
    
    Changetax2Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    Changetax2Btn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+10,95,30, 30);
    [Changetax2Btn addTarget:self action:@selector(ChangeTax2Clikced) forControlEvents:UIControlEventTouchUpInside];
    [Changetax2Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[Changetax2Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[Changetax2Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [Changetax2Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [Changetax2Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [EditProductView addSubview:Changetax2Btn];
      if (!Changetax2lbl)
    Changetax2lbl=[[UILabel alloc] init];
    Changetax2lbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+45,90,50, 40);
    [Changetax2lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Changetax2lbl setBackgroundColor:[UIColor clearColor]];
    [Changetax2lbl setTextColor:[UIColor whiteColor]];
    
    [Changetax2lbl setText:tax2Name];
    
    [Changetax2lbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductView addSubview:Changetax2lbl];
    
    Changetax3Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    Changetax3Btn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+10,155,30, 30);
    [Changetax3Btn addTarget:self action:@selector(ChangeTax3Clicked) forControlEvents:UIControlEventTouchUpInside];
    [Changetax3Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[Changetax3Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[Changetax3Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [Changetax3Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [Changetax3Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [EditProductView addSubview:Changetax3Btn];
      if (!Changetax3lbl)
    Changetax3lbl=[[UILabel alloc] init];
    Changetax3lbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+45,150,50, 40);
    [Changetax3lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Changetax3lbl setBackgroundColor:[UIColor clearColor]];
    [Changetax3lbl setTextColor:[UIColor whiteColor]];
    
    [Changetax3lbl setText:tax3Name];
    
    [Changetax3lbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductView addSubview:Changetax3lbl];
    
    ChangeBarTaxBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    ChangeBarTaxBtn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+10,215,30, 30);
    [ChangeBarTaxBtn addTarget:self action:@selector(ChangeBarBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [ChangeBarTaxBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[ChangeBarTaxBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[ChangeBarTaxBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    
    [ChangeBarTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [ChangeBarTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [EditProductView addSubview:ChangeBarTaxBtn];
      if (!Changebartaxlbl)
    Changebartaxlbl=[[UILabel alloc] init];
    Changebartaxlbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+45,210,80, 40);
    [Changebartaxlbl setFont:[UIFont systemFontOfSize:18.0f]];
    [Changebartaxlbl setBackgroundColor:[UIColor clearColor]];
    [Changebartaxlbl setTextColor:[UIColor whiteColor]];
    [Changebartaxlbl setText:@"Bartax"];
    [Changebartaxlbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductView addSubview:Changebartaxlbl];
    if ([tax1value isEqualToString:tax1Name]){
        Changetax1Btn.selected=YES;
        
    }else{
        Changetax1Btn.selected=NO;
    }
    if ([tax2value isEqualToString:tax2Name]){
        Changetax2Btn.selected=YES;
        
    }else{
        Changetax2Btn.selected=NO;
    }
    if ([tax3value isEqualToString:tax3Name]){
        Changetax3Btn.selected=YES;
        
    } else{
        Changetax3Btn.selected=NO;
    }
    if ([bartaxvalue isEqualToString:@"Bartax"]){
        ChangeBarTaxBtn.selected=YES;
        
    }else{
        ChangeBarTaxBtn.selected=NO;
    }
     NSArray *array2=[[NSArray alloc]initWithObjects:@"Optional Info",@"Notes",@"Modifiers",nil];
      NSArray *array3=[[NSArray alloc]initWithObjects:@"Ordering Info",@"SalesHistory", @"printers",nil];
    @autoreleasepool {
        CGFloat wdth=(EditProductView.frame.size.width)/4;
        CGFloat xvalue=wdth/4;
        for (int k=0; k<3; k++)
        {
            ChangeinfoButtons = [UIButton buttonWithType:UIButtonTypeRoundedRect];
           
            [ChangeinfoButtons setTitle:[array2 objectAtIndex:k] forState:UIControlStateNormal];
            //[ChangeinfoButtons setBackgroundImage:[UIImage imageNamed:@"additionaloptions.png"] forState:UIControlStateNormal];
            [ChangeinfoButtons setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"additionaloptions" ofType:@"png"]] forState:UIControlStateNormal];
            ChangeinfoButtons.frame=CGRectMake(xvalue+20,350,wdth+5, 40);
            
            [ChangeinfoButtons addTarget:self action:@selector(ChangeinfoButton1Clicked:) forControlEvents:UIControlEventTouchUpInside];
            ChangeinfoButtons.tag=k+100;
            [ChangeinfoButtons setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            
            [EditProductView addSubview:ChangeinfoButtons];
            xvalue=xvalue+wdth+15;
            
        }
        CGFloat wdth2=(EditProductView.frame.size.width)/4;
        CGFloat valuex=wdth2/4;
        for (int j=0; j<3; j++)
        {
            ChangeinfoButton2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            [ChangeinfoButton2 setTitle:[array3 objectAtIndex:j] forState:UIControlStateNormal];
            //[ChangeinfoButton2 setBackgroundImage:[UIImage imageNamed:@"additionaloptions.png"] forState:UIControlStateNormal];
            [ChangeinfoButton2 setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"additionaloptions" ofType:@"png"]] forState:UIControlStateNormal];
            ChangeinfoButton2.frame=CGRectMake(valuex+20,400,wdth2+5, 40);
            [ChangeinfoButton2 addTarget:self action:@selector(ChangeinfoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
            
            [ChangeinfoButton2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            ChangeinfoButton2.tag=j+100;
            [EditProductView addSubview:ChangeinfoButton2];
            if (ChangeinfoButton2.tag==102)
            {
                ChangeinfoButton2.hidden=YES;
            }
            
            valuex=valuex+wdth2+15;
            
        }
    }
    
    @autoreleasepool {
        ChangeSaveProductBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        ChangeSaveProductBtn.frame=CGRectMake(changeProductfieldwidth+130, 480, 80,30);
        [ChangeSaveProductBtn addTarget:self action:@selector(SaveChangeProductData) forControlEvents:UIControlEventTouchUpInside];
         //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [ChangeSaveProductBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[ChangeSaveProductBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [ChangeSaveProductBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        [EditProductView addSubview:ChangeSaveProductBtn];
        
        ChangeCancelProductBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        ChangeCancelProductBtn.frame=CGRectMake(changeProductfieldwidth+240, 480, 80, 30);
        [ChangeCancelProductBtn addTarget:self action:@selector(CancelChageProductData) forControlEvents:UIControlEventTouchUpInside];
        [ChangeCancelProductBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[ChangeCancelProductBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
         [ChangeCancelProductBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [EditProductView addSubview:ChangeCancelProductBtn];
    }
    array=nil,array2=nil,array3=nil;
    Deptstr=nil;
    itemnumber=nil;
    itemname=nil;
    des=nil;
    cost=nil;
    priceyoucharge=nil;
    pricewithtax=nil;
    instock=nil;
    vendorno=nil;
    taxstr=nil;
      tax1value=nil,tax2value=nil,tax3value=nil,bartaxvalue=nil;
    paddingview=nil,paddingview2=nil,paddingview3=nil,paddingview4=nil,paddingview5=nil;
}
-(void) viewProductViewremove
{
    NSArray * depertmentViewArray = InstantPOView.subviews;
    for (int i = 0; i<[depertmentViewArray count]; i++) {
        UIView *vi =[depertmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addDepartmentViewArray = InstantPoPOPupView.subviews;
    for (int i = 0; i<[addDepartmentViewArray count]; i++) {
        UIView *vi =[addDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [InstantPOView removeFromSuperview],[InstantPoPOPupView removeFromSuperview];
    
}
- (IBAction)product_viewButtonClicked:(id)sender
{
    UIButton *but =sender;
    // //NSLog(@"ViewButton %d",but.tag);
    
    NSInteger  selectedrow=but.tag-1;
   InvItemNumber=[ItemNumbersArray objectAtIndex:selectedrow];
    NSString *instock=[InstockArray objectAtIndex:selectedrow];
    
    InstantPoPOPupView=[[UIView alloc]init];
    if (isLandScope) {
        InstantPoPOPupView.frame=CGRectMake(0, 0, 1024, 768);
    }else{
        
        InstantPoPOPupView.frame=CGRectMake(0, 0, 768, 1024);
    }
    [InstantPoPOPupView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:InstantPoPOPupView];
    InstantPOView=[[UIScrollView alloc]init];
    if (isLandScope)
    {
        InstantPOView.frame=CGRectMake(200, 200, InstantPoPOPupView.frame.size.width-400, InstantPoPOPupView.frame.size.height-400);
    }else{
        InstantPOView.frame=CGRectMake(150, 300, InstantPoPOPupView.frame.size.width-300, InstantPoPOPupView.frame.size.height-700);
    }
    
    [InstantPOView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    
    [InstantPOView.layer setBorderWidth:2.0];
    [InstantPOView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
    //AddvendorsView.layer.cornerRadius=8;
    [InstantPoPOPupView addSubview:InstantPOView];
    CGFloat instwidth=(InstantPOView.frame.size.width)/2;
    CGFloat inst=instwidth/2;
    Instantpolbl=[[UILabel alloc] init];
    Instantpolbl.frame=CGRectMake(inst-60, 90,instwidth-10, 50);
    
    [Instantpolbl setFont:[UIFont systemFontOfSize:25.0f]];
    [Instantpolbl setBackgroundColor:[UIColor clearColor]];
    [Instantpolbl setTextColor:[UIColor whiteColor]];
    [Instantpolbl setText:@"Instock"];
    Instantpolbl.lineBreakMode = NSLineBreakByWordWrapping;
    Instantpolbl.numberOfLines = 2;
    [Instantpolbl setTextAlignment:NSTextAlignmentLeft];
    [InstantPOView addSubview:Instantpolbl];
    InstantpoField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    InstantpoField.frame=CGRectMake(Instantpolbl.frame.size.width-40, 95,instwidth-10, 40);
    InstantpoField.delegate=self;
    InstantpoField.text=instock;
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    InstantpoField.leftView = paddingview;
    InstantpoField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    InstantpoField.leftViewMode = UITextFieldViewModeAlways;
    //[InstantpoField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [InstantpoField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    
    
    [InstantpoField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [InstantPOView addSubview:InstantpoField];
    SaveInstantPoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    SaveInstantPoBtn.frame=CGRectMake(instwidth-90, 180, 80, 30);
    [SaveInstantPoBtn addTarget:self action:@selector(SaveInstantPO) forControlEvents:UIControlEventTouchUpInside];
    
    //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
    [SaveInstantPoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //[SaveInstantPoBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
    [SaveInstantPoBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
    [InstantPOView addSubview:SaveInstantPoBtn];
    
    CancelInstantpoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    CancelInstantpoBtn.frame=CGRectMake(instwidth+40, 180, 80, 30);
    [CancelInstantpoBtn addTarget:self action:@selector(CancelInstantProductData) forControlEvents:UIControlEventTouchUpInside];
    [CancelInstantpoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //[CancelInstantpoBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
    [CancelInstantpoBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [InstantPOView addSubview:CancelInstantpoBtn];
    
}
-(void) duplicateProductViewremove
{
   
    NSArray * depertmentViewArray = DuplicateProductView.subviews;
    for (int i = 0; i<[depertmentViewArray count]; i++) {
        UIView *vi =[depertmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addDepartmentViewArray = DuplicateproductPopUpView.subviews;
    for (int i = 0; i<[addDepartmentViewArray count]; i++) {
        UIView *vi =[addDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [DuplicateProductView removeFromSuperview],[DuplicateproductPopUpView removeFromSuperview];
}
- (IBAction)product_duplicateButtonClicked:(id)sender
{
    
    EditmodifierItem=@"no";
    EditCountthisItem=@"no";
    Editallowbuyback=@"no";
    Editprintonreceipt=@"no";
    Editfoodstampable=@"no";
    Editpromptprice=@"no";

    UIButton *but =sender;
    // //NSLog(@"DuplicateButton %d",but.tag);
    
    NSInteger  selectedrow=but.tag-1;
    DuplicateproductPopUpView=[[UIView alloc]init];
    if (isLandScope) {
        DuplicateproductPopUpView.frame=CGRectMake(0, 0, 1024, 768);
    }
    
    else{
        
        DuplicateproductPopUpView.frame=CGRectMake(0, 0, 768, 1024);
    }
    [DuplicateproductPopUpView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:DuplicateproductPopUpView];
    
    DuplicateProductView=[[UIScrollView alloc]init];
    if (isLandScope) {
        
        DuplicateProductView.frame=CGRectMake(20, 40, DuplicateproductPopUpView.frame.size.width-40, DuplicateproductPopUpView.frame.size.height-80);
    }
    else
    {
        DuplicateProductView.frame=CGRectMake(20, 150, DuplicateproductPopUpView.frame.size.width-40, DuplicateproductPopUpView.frame.size.height-400);
    }
    [DuplicateProductView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    DuplicateProductView.contentSize=CGSizeMake(DuplicateproductPopUpView.frame.size.width-40, DuplicateproductPopUpView.frame.size.height-20+300);
    [DuplicateProductView.layer setBorderWidth:2.0];
    [DuplicateProductView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
    //AddvendorsView.layer.cornerRadius=8;
    [DuplicateproductPopUpView addSubview:DuplicateProductView];
    
    
    
    NSString *Deptstr=[ProductDepartmentsArray objectAtIndex:selectedrow];
    NSString *itemnumber=[ItemNumbersArray objectAtIndex:selectedrow];
    NSString *itemname=[ItemnameArray objectAtIndex:selectedrow];
    NSString *des=[productDesArray objectAtIndex:selectedrow];
    NSString *cost=[CostArray objectAtIndex:selectedrow];
    NSString *priceyoucharge=[priceyouchargeArray objectAtIndex:selectedrow];
    NSString *pricewithtax=[pricewithTaxArray objectAtIndex:selectedrow];
    NSString *instock=[InstockArray objectAtIndex:selectedrow];
    NSString *vendorno=[productVendorsArray objectAtIndex:selectedrow];
    NSString *taxstr=[taxvaluesArray objectAtIndex:selectedrow];
    // //NSLog(@"%@",taxstr);
    
    
    
    EditProductNotes=[productNotesArray objectAtIndex:selectedrow];
    
    NSString *querySQL = [NSString stringWithFormat: @"SELECT inventary_modifier_item,inventary_count_this_item,inventary_prompt_quantity,inventary_print_on_receipt,inventary_foodstampable,inventary_prompt_price,bonus_points,barcodes,location,unit_size,unit_type,commission_optional_info FROM optional_info_table WHERE inventory_item_no='%@'",itemnumber];
    NSMutableArray *optionalinfoArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:optionalinfoArray];
    
    @autoreleasepool {
        for (NSDictionary *myDict in optionalinfoArray)
        {
            EditmodifierItem=[myDict objectForKey:@"inventary_modifier_item"];
            EditCountthisItem=[myDict objectForKey:@"inventary_count_this_item"];
            Editallowbuyback=[myDict objectForKey:@"inventary_prompt_quantity"];
            Editprintonreceipt=[myDict objectForKey:@"inventary_print_on_receipt"];
            Editfoodstampable=[myDict objectForKey:@"inventary_foodstampable"];
            Editpromptprice=[myDict objectForKey:@"inventary_prompt_price"];
            
            Editbonuspoint=[myDict objectForKey:@"bonus_points"];
            
            Editbarcode=[myDict objectForKey:@"barcodes"];
            Editlocation=[myDict objectForKey:@"location"];
            Editunitsize=[myDict objectForKey:@"unit_size"];
            EditUnittype=[myDict objectForKey:@"unit_type"];
            Editcommission=[myDict objectForKey:@"commission_optional_info"];
        }
        
    }
    
    NSString *skuquerySQL = [NSString stringWithFormat: @"SELECT alternate_sku_value FROM alternate_sku WHERE inventory_item_no='%@'",itemnumber];
    NSMutableArray *skusArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:skuquerySQL resultsArray:skusArray];
    
    
        SkusArray=[[NSMutableArray alloc]init];
        SelectedSkusArray=[[NSMutableArray alloc]init];
        
        for (NSDictionary *myDict in skusArray)
        {
            [SelectedSkusArray addObject:[myDict objectForKey:@"alternate_sku_value"]];
        }
    
    NSString *modquerySQL = [NSString stringWithFormat:@"SELECT modifier_item_no,inventary_item_name FROM modifier_table WHERE inventory_item_no='%@'",itemnumber];
    NSMutableArray *modsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:modquerySQL resultsArray:modsArray];
    
   
        ModifierItemNosArray=[[NSMutableArray alloc]init];
        selectedModifiers=[[NSMutableArray alloc]init];
        modifierNamesArray=[[NSMutableArray alloc]init];
        SelectedNamesArray=[[NSMutableArray alloc]init];
        @autoreleasepool {
            for (NSDictionary *myDict in modsArray)
            {
                [selectedModifiers addObject:[myDict objectForKey:@"modifier_item_no"]];
                [SelectedNamesArray addObject:[myDict objectForKey:@"inventary_item_name"]];
                
            }
        }
   
    
    NSString *orderquerySQL = [NSString stringWithFormat: @"SELECT vendor_company_name,venderpart_no,cost_per,case_cost,no_in_case,preferred FROM ordering_info_table WHERE inventory_item_no='%@'",itemnumber];
    NSMutableArray *orderinfosArray=[[NSMutableArray alloc]init];
    
    [[DataBaseManager dataBaseManager]execute:orderquerySQL resultsArray:orderinfosArray];
   
        SelectedOpVendorsArray=[[NSMutableArray alloc] init];
        VendorPartsArray=[[NSMutableArray alloc] init];
        CostpersArray=[[NSMutableArray alloc] init];
        CasecostsArray=[[NSMutableArray alloc] init];
        NumberincasesArray=[[NSMutableArray alloc] init];
        preferredsArray=[[NSMutableArray alloc] init];
        
        @autoreleasepool {
            for (NSDictionary *myDict in orderinfosArray)
            {
                [SelectedOpVendorsArray addObject:[myDict objectForKey:@"vendor_company_name"]];
                [VendorPartsArray addObject:[myDict objectForKey:@"venderpart_no"]];
                [CostpersArray addObject:[myDict objectForKey:@"cost_per"]];
                [CasecostsArray addObject:[myDict objectForKey:@"case_cost"]];
                [NumberincasesArray addObject:[myDict objectForKey:@"no_in_case"]];
                [preferredsArray addObject:[myDict objectForKey:@"preferred"]];
                
            }
        }
   
    
    NSArray *array=[taxstr componentsSeparatedByString:@","];
    NSString *tax1value,*tax2value,*tax3value,*bartaxvalue;
    for (int i=0; i<[array count]; i++)
    {
        
        NSString  *tvalue=[array objectAtIndex:i];
        if ([tvalue isEqualToString:tax1Name])
        {
            tax1value=tvalue;
        }
        if ([tvalue isEqualToString:tax2Name])
        {
            tax2value=tvalue;
        }
        if ([tvalue isEqualToString:tax3Name])
        {
            tax3value=tvalue;
        }
        if ([tvalue isEqualToString:@"Bartax"])
        {
            bartaxvalue=tvalue;
        }
        
        
        
        
        
    }
    
    CGFloat DuplicateProductfieldwidth=(DuplicateProductView.frame.size.width-100)/4;
    CGFloat Dp=(DuplicateProductfieldwidth/2)+20;
    
    DuplicateDepartmentlbl=[[UILabel alloc] init];
    DuplicateDepartmentlbl.frame=CGRectMake(Dp-80, 30,DuplicateProductfieldwidth, 50);
    
    [DuplicateDepartmentlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [DuplicateDepartmentlbl setBackgroundColor:[UIColor clearColor]];
    [DuplicateDepartmentlbl setTextColor:[UIColor whiteColor]];
    [DuplicateDepartmentlbl setText:@"Department for this Item"];
    DuplicateDepartmentlbl.lineBreakMode = NSLineBreakByWordWrapping;
    DuplicateDepartmentlbl.numberOfLines = 2;
    [DuplicateDepartmentlbl setTextAlignment:NSTextAlignmentLeft];
    [DuplicateProductView addSubview:DuplicateDepartmentlbl];
    
    NSString *querySQL7 = [NSString stringWithFormat: @"SELECT department_id FROM department_details"];
    NSMutableArray *deptsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:deptsArray];
    DepartmentNamesArray=[[NSMutableArray alloc]init];
    @autoreleasepool {
        for (NSDictionary *myDict in deptsArray)
        {
            NSString *catname=[myDict objectForKey:@"department_id"];
            [DepartmentNamesArray addObject:catname];
            
        }
    }
   
    DuplicateDepartmentBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DuplicateDepartmentBtn.frame=CGRectMake(DuplicateProductfieldwidth+5, 30, DuplicateProductfieldwidth-10, 40);
    [DuplicateDepartmentBtn addTarget:self action:@selector(DepartmentDuplicateBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [DuplicateDepartmentBtn setTitle:Deptstr forState:UIControlStateNormal];
    [DuplicateDepartmentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DuplicateDepartmentBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [DuplicateDepartmentBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [DuplicateProductView addSubview:DuplicateDepartmentBtn];
    
    DuplicateDepartmentsTable = [[UITableView alloc] initWithFrame:CGRectMake(DuplicateProductfieldwidth+5, 70, DuplicateProductfieldwidth-10, 100) style:UITableViewStylePlain];
    DuplicateDepartmentsTable.backgroundColor=[UIColor whiteColor];
    DuplicateDepartmentsTable.delegate = self;
    DuplicateDepartmentsTable.dataSource = self;
    DuplicateDepartmentsTable.scrollEnabled = YES;
    DuplicateDepartmentsTable.hidden=YES;
    [DuplicateDepartmentsTable.layer setBorderWidth: 1.0];
    [DuplicateDepartmentsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [DuplicateProductView addSubview:DuplicateDepartmentsTable];
    
    DuplicateItemNumberlbl=[[UILabel alloc] init];
    DuplicateItemNumberlbl.frame=CGRectMake(Dp-80, 90,DuplicateProductfieldwidth, 40);
    [DuplicateItemNumberlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [DuplicateItemNumberlbl setBackgroundColor:[UIColor clearColor]];
    [DuplicateItemNumberlbl setTextColor:[UIColor whiteColor]];
    [DuplicateItemNumberlbl setText:@"Item Number"];
    [DuplicateItemNumberlbl setTextAlignment:NSTextAlignmentLeft];
    [DuplicateProductView addSubview:DuplicateItemNumberlbl];
    
    DuplicateItemNumberField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    DuplicateItemNumberField.frame=CGRectMake(DuplicateProductfieldwidth+5, 90,DuplicateProductfieldwidth-10, 40);
    DuplicateItemNumberField.delegate=self;
    DuplicateItemNumberField.text=itemnumber;
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    DuplicateItemNumberField.leftView = paddingview;
    DuplicateItemNumberField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    DuplicateItemNumberField.leftViewMode = UITextFieldViewModeAlways;
    //[DuplicateItemNumberField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [DuplicateItemNumberField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [DuplicateItemNumberField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [DuplicateProductView addSubview:DuplicateItemNumberField];
    
    DuplicateItemNamelbl=[[UILabel alloc] init];
    DuplicateItemNamelbl.frame=CGRectMake(Dp-80, 150,DuplicateProductfieldwidth, 40);
    [DuplicateItemNamelbl setFont:[UIFont systemFontOfSize:20.0f]];
    [DuplicateItemNamelbl setBackgroundColor:[UIColor clearColor]];
    [DuplicateItemNamelbl setTextColor:[UIColor whiteColor]];
    [DuplicateItemNamelbl setText:@"Item Name"];
    [DuplicateItemNamelbl setTextAlignment:NSTextAlignmentLeft];
    [DuplicateProductView addSubview:DuplicateItemNamelbl];
    
    DuplicateItemNameField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    DuplicateItemNameField.frame=CGRectMake(DuplicateProductfieldwidth+5, 150,DuplicateProductfieldwidth-10, 40);
    DuplicateItemNameField.delegate=self;
    UIView *paddingview2=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    DuplicateItemNameField.leftView = paddingview2;
    DuplicateItemNameField.text=itemname;
    DuplicateItemNameField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    DuplicateItemNameField.leftViewMode = UITextFieldViewModeAlways;
    //[DuplicateItemNameField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    
    [DuplicateItemNameField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [DuplicateItemNameField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [DuplicateProductView addSubview:DuplicateItemNameField];
    
    DuplicateDescroptionlbl=[[UILabel alloc] init];
    DuplicateDescroptionlbl.frame=CGRectMake(Dp-80, 210,DuplicateProductfieldwidth+10, 40);
    [DuplicateDescroptionlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [DuplicateDescroptionlbl setBackgroundColor:[UIColor clearColor]];
    [DuplicateDescroptionlbl setTextColor:[UIColor whiteColor]];
    [DuplicateDescroptionlbl setText:@"2nd Description"];
    [DuplicateDescroptionlbl setTextAlignment:NSTextAlignmentLeft];
    [DuplicateProductView addSubview:DuplicateDescroptionlbl];
    
    DuplicateDescriptionText=[[UITextView alloc] init];
    DuplicateDescriptionText.frame=CGRectMake(DuplicateProductfieldwidth+5, 200,DuplicateProductfieldwidth-10,80);
    DuplicateDescriptionText.delegate=self;
    DuplicateDescriptionText.font=[UIFont systemFontOfSize:14.0f];
    DuplicateDescriptionText.text=des;
    [DuplicateDescriptionText setAutocorrectionType:UITextAutocorrectionTypeNo];
    DuplicateDescriptionText.layer.cornerRadius=8;
    [DuplicateProductView addSubview:DuplicateDescriptionText];
    
    DuplicateCostlbl=[[UILabel alloc] init];
    DuplicateCostlbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+15, 30,DuplicateProductfieldwidth+10, 40);
    [DuplicateCostlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [DuplicateCostlbl setBackgroundColor:[UIColor clearColor]];
    [DuplicateCostlbl setTextColor:[UIColor whiteColor]];
    
    [DuplicateCostlbl setText:@"Cost"];
    [DuplicateCostlbl setTextAlignment:NSTextAlignmentLeft];
    [DuplicateProductView addSubview:DuplicateCostlbl];
    
    DuplicateCostField=[[UITextField alloc] init];
    DuplicateCostField.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5, 30,DuplicateProductfieldwidth-10, 40);
    [DuplicateCostField addTarget:self action:@selector(AddressFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
    DuplicateCostField.delegate=self;
    UIView *paddingview3=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    DuplicateCostField.leftView = paddingview3;
    DuplicateCostField.text=cost;
    DuplicateCostField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    DuplicateCostField.leftViewMode = UITextFieldViewModeAlways;
    //[DuplicateCostField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [DuplicateCostField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [DuplicateCostField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [DuplicateProductView addSubview:DuplicateCostField];
    
    DuplicatepriceyouChargelbl=[[UILabel alloc] init];
    DuplicatepriceyouChargelbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+15,90,DuplicateProductfieldwidth+10, 40);
    [DuplicatepriceyouChargelbl setFont:[UIFont systemFontOfSize:20.0f]];
    [DuplicatepriceyouChargelbl setBackgroundColor:[UIColor clearColor]];
    [DuplicatepriceyouChargelbl setTextColor:[UIColor whiteColor]];
    [DuplicatepriceyouChargelbl setText:@"Price You Charge"];
    [DuplicatepriceyouChargelbl setTextAlignment:NSTextAlignmentLeft];
    [DuplicateProductView addSubview:DuplicatepriceyouChargelbl];
    
    DuplicatePriceyouChargeField=[[UITextField alloc] init];
    DuplicatePriceyouChargeField.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5,90,DuplicateProductfieldwidth-10, 40);
    [DuplicatePriceyouChargeField addTarget:self action:@selector(PriceYouChargeClicked:) forControlEvents:UIControlEventEditingDidEnd];
    DuplicatePriceyouChargeField.delegate=self;
    UIView *paddingview4=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    DuplicatePriceyouChargeField.leftView = paddingview4;
    DuplicatePriceyouChargeField.text=priceyoucharge;
    DuplicatePriceyouChargeField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    DuplicatePriceyouChargeField.leftViewMode = UITextFieldViewModeAlways;
    //[DuplicatePriceyouChargeField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [DuplicatePriceyouChargeField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    
    [DuplicatePriceyouChargeField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [DuplicateProductView addSubview:DuplicatePriceyouChargeField];
    
    DuplicatepriceWithTaxlbl=[[UILabel alloc] init];
    DuplicatepriceWithTaxlbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+15,150,DuplicateProductfieldwidth+10, 40);
    [DuplicatepriceWithTaxlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [DuplicatepriceWithTaxlbl setBackgroundColor:[UIColor clearColor]];
    [DuplicatepriceWithTaxlbl setTextColor:[UIColor whiteColor]];
    
    [DuplicatepriceWithTaxlbl setText:@"Price with Tax"];
    [DuplicatepriceWithTaxlbl setTextAlignment:NSTextAlignmentLeft];
    [DuplicateProductView addSubview:DuplicatepriceWithTaxlbl];
    
    DuplicatePriceWithTaxBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DuplicatePriceWithTaxBtn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5,150,DuplicateProductfieldwidth-10, 40);
    [DuplicatePriceWithTaxBtn addTarget:self action:@selector(DuplicatepricewithTaxClicked) forControlEvents:UIControlEventTouchUpInside];
    [DuplicatePriceWithTaxBtn setTitle:pricewithtax forState:UIControlStateNormal];
    [DuplicatePriceWithTaxBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DuplicatePriceWithTaxBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
    [DuplicatePriceWithTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]] forState:UIControlStateNormal];
    [DuplicateProductView addSubview:DuplicatePriceWithTaxBtn];
    
    DuplicateInStocklbl=[[UILabel alloc] init];
    DuplicateInStocklbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+15,210,DuplicateProductfieldwidth+10, 40);
    [DuplicateInStocklbl setFont:[UIFont systemFontOfSize:20.0f]];
    [DuplicateInStocklbl setBackgroundColor:[UIColor clearColor]];
    [DuplicateInStocklbl setTextColor:[UIColor whiteColor]];
    
    [DuplicateInStocklbl setText:@"In Stock"];
    [DuplicateInStocklbl setTextAlignment:NSTextAlignmentLeft];
    [DuplicateProductView addSubview:DuplicateInStocklbl];
    
    DuplicateInStockField=[[UITextField alloc] init];
    DuplicateInStockField.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5,210,DuplicateProductfieldwidth-10, 40);
    [DuplicateInStockField addTarget:self action:@selector(AddressFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
    DuplicateInStockField.delegate=self;
    UIView *paddingview5=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    DuplicateInStockField.leftView = paddingview5;
    DuplicateInStockField.text=instock;
    DuplicateInStockField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    DuplicateInStockField.leftViewMode = UITextFieldViewModeAlways;
    // [DuplicateInStockField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [DuplicateInStockField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [DuplicateInStockField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [DuplicateProductView addSubview:DuplicateInStockField];
    
    DuplicateAddpricinglbl=[[UILabel alloc] init];
    DuplicateAddpricinglbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+15,270,DuplicateProductfieldwidth+10, 50);
    [DuplicateAddpricinglbl setFont:[UIFont systemFontOfSize:20.0f]];
    [DuplicateAddpricinglbl setBackgroundColor:[UIColor clearColor]];
    [DuplicateAddpricinglbl setTextColor:[UIColor whiteColor]];
    
    [DuplicateAddpricinglbl setText:@"Addpricing from a Vendor"];
    DuplicateAddpricinglbl.lineBreakMode = NSLineBreakByWordWrapping;
    DuplicateAddpricinglbl.numberOfLines = 2;
    [DuplicateAddpricinglbl setTextAlignment:NSTextAlignmentLeft];
    [DuplicateProductView addSubview:DuplicateAddpricinglbl];
    
    VendornumbersArray=[[NSMutableArray alloc]init];
     NSString *vendorquerySQL = [NSString stringWithFormat: @"SELECT vendor_no FROM vendor"];
    NSMutableArray *vendorsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:vendorquerySQL resultsArray:vendorsArray];
    @autoreleasepool {
        for (NSDictionary *myDict in vendorsArray)
        {
            NSString *vendorno=[myDict objectForKey:@"vendor_no"];
            
            [VendornumbersArray addObject:vendorno];
        }
    }
   
    DuplicateAddpricingBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    DuplicateAddpricingBtn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5,270,DuplicateProductfieldwidth-10, 40);
    [DuplicateAddpricingBtn addTarget:self action:@selector(DuplicateAddpricingClicked) forControlEvents:UIControlEventTouchUpInside];
    [DuplicateAddpricingBtn setTitle:vendorno forState:UIControlStateNormal];
    [DuplicateAddpricingBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DuplicateAddpricingBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [DuplicateAddpricingBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [DuplicateProductView addSubview:DuplicateAddpricingBtn];
    
    
    DuplicateVendorsTable = [[UITableView alloc] initWithFrame:CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5,170,DuplicateProductfieldwidth-10, 100) style:UITableViewStylePlain];
    DuplicateVendorsTable.backgroundColor=[UIColor whiteColor];
    DuplicateVendorsTable.delegate = self;
    DuplicateVendorsTable.dataSource = self;
    DuplicateVendorsTable.scrollEnabled = YES;
    DuplicateVendorsTable.hidden=YES;
    [DuplicateVendorsTable.layer setBorderWidth: 1.0];
    [DuplicateVendorsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [DuplicateProductView addSubview:DuplicateVendorsTable];
    
    Duplicatetax1Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    Duplicatetax1Btn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+10,35,30, 30);
    [Duplicatetax1Btn addTarget:self action:@selector(DuplicateTax1Clicked) forControlEvents:UIControlEventTouchUpInside];
    [Duplicatetax1Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[Duplicatetax1Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[Duplicatetax1Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    
    [Duplicatetax1Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [Duplicatetax1Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    [DuplicateProductView addSubview:Duplicatetax1Btn];
    
    Duplicatetax1lbl=[[UILabel alloc] init];
    Duplicatetax1lbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+45,30,50, 40);
    [Duplicatetax1lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Duplicatetax1lbl setBackgroundColor:[UIColor clearColor]];
    [Duplicatetax1lbl setTextColor:[UIColor whiteColor]];
    //tax1Btn.selected=YES;
    [Duplicatetax1lbl setText:tax1Name];
    [Duplicatetax1lbl setTextAlignment:NSTextAlignmentLeft];
    [DuplicateProductView addSubview:Duplicatetax1lbl];
    
    
    Duplicatetax2Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    Duplicatetax2Btn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+10,95,30, 30);
    [Duplicatetax2Btn addTarget:self action:@selector(DuplicateTax2Clikced) forControlEvents:UIControlEventTouchUpInside];
    [Duplicatetax2Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[Duplicatetax2Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[Duplicatetax2Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [Duplicatetax2Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [Duplicatetax2Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [DuplicateProductView addSubview:Duplicatetax2Btn];
    
    Duplicatetax2lbl=[[UILabel alloc] init];
    Duplicatetax2lbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+45,90,50, 40);
    [Duplicatetax2lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Duplicatetax2lbl setBackgroundColor:[UIColor clearColor]];
    [Duplicatetax2lbl setTextColor:[UIColor whiteColor]];
    
    [Duplicatetax2lbl setText:tax2Name];
    
    [Duplicatetax2lbl setTextAlignment:NSTextAlignmentLeft];
    [DuplicateProductView addSubview:Duplicatetax2lbl];
    
    Duplicatetax3Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    Duplicatetax3Btn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+10,155,30, 30);
    [Duplicatetax3Btn addTarget:self action:@selector(DuplicateTax3Clicked) forControlEvents:UIControlEventTouchUpInside];
    [Duplicatetax3Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[Duplicatetax3Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[Duplicatetax3Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [Duplicatetax3Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [Duplicatetax3Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [DuplicateProductView addSubview:Duplicatetax3Btn];
    
    Duplicatetax3lbl=[[UILabel alloc] init];
    Duplicatetax3lbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+45,150,50, 40);
    [Duplicatetax3lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Duplicatetax3lbl setBackgroundColor:[UIColor clearColor]];
    [Duplicatetax3lbl setTextColor:[UIColor whiteColor]];
    
    [Duplicatetax3lbl setText:tax3Name];
    
    [Duplicatetax3lbl setTextAlignment:NSTextAlignmentLeft];
    [DuplicateProductView addSubview:Duplicatetax3lbl];
    
    DuplicateBarTaxBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DuplicateBarTaxBtn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+10,215,30, 30);
    [DuplicateBarTaxBtn addTarget:self action:@selector(DuplicateBarBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [DuplicateBarTaxBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DuplicateBarTaxBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[DuplicateBarTaxBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    
    [DuplicateBarTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [DuplicateBarTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    [DuplicateProductView addSubview:DuplicateBarTaxBtn];
    
    Duplicatebartaxlbl=[[UILabel alloc] init];
    Duplicatebartaxlbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+45,210,80, 40);
    [Duplicatebartaxlbl setFont:[UIFont systemFontOfSize:18.0f]];
    [Duplicatebartaxlbl setBackgroundColor:[UIColor clearColor]];
    [Duplicatebartaxlbl setTextColor:[UIColor whiteColor]];
    [Duplicatebartaxlbl setText:@"Bartax"];
    [Duplicatebartaxlbl setTextAlignment:NSTextAlignmentLeft];
    [DuplicateProductView addSubview:Duplicatebartaxlbl];
    
    
    if ([tax1value isEqualToString:tax1Name])
    {
        Duplicatetax1Btn.selected=YES;
        
    }
    else
    {
        Duplicatetax1Btn.selected=NO;
    }
    if ([tax2value isEqualToString:tax2Name])
    {
        Duplicatetax2Btn.selected=YES;
        
    }
    else
    {
        Duplicatetax2Btn.selected=NO;
    }
    if ([tax3value isEqualToString:tax3Name])
    {
        Duplicatetax3Btn.selected=YES;
        
    }
    else
    {
        Duplicatetax3Btn.selected=NO;
    }
    if ([bartaxvalue isEqualToString:@"Bartax"])
    {
        DuplicateBarTaxBtn.selected=YES;
        
    }
    else
    {
        DuplicateBarTaxBtn.selected=NO;
    }
    
    
    CGFloat Dwdth=(DuplicateProductView.frame.size.width)/4;
    CGFloat Dvalue=Dwdth/4;
    for (int k=0; k<3; k++)
    {
        DuplicateinfoButtons = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        NSArray *array2=[[NSArray alloc]initWithObjects:@"Optional Info",@"Notes",@"Modifiers",nil];
        [DuplicateinfoButtons setTitle:[array2 objectAtIndex:k] forState:UIControlStateNormal];
        //[DuplicateinfoButtons setBackgroundImage:[UIImage imageNamed:@"additionaloptions.png"] forState:UIControlStateNormal];
        [DuplicateinfoButtons setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"additionaloptions" ofType:@"png"]] forState:UIControlStateNormal];
        DuplicateinfoButtons.frame=CGRectMake(Dvalue+20,350,Dwdth+5, 40);
        
        [DuplicateinfoButtons addTarget:self action:@selector(DuplicateinfoButton1Clicked:) forControlEvents:UIControlEventTouchUpInside];
        DuplicateinfoButtons.tag=k+100;
        [DuplicateinfoButtons setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        [DuplicateProductView addSubview:DuplicateinfoButtons];
        Dvalue=Dvalue+Dwdth+15;
        
    }
    
    CGFloat Dwdth2=(DuplicateProductView.frame.size.width)/4;
    CGFloat Dvaluex=Dwdth2/4;
    for (int j=0; j<3; j++)
    {
        DuplicateinfoButton2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        NSArray *array=[[NSArray alloc]initWithObjects:@"Ordering Info",@"SalesHistory", @"printers",nil];
        [DuplicateinfoButton2 setTitle:[array objectAtIndex:j] forState:UIControlStateNormal];
        // [DuplicateinfoButton2 setBackgroundImage:[UIImage imageNamed:@"additionaloptions.png"] forState:UIControlStateNormal];
        [DuplicateinfoButton2 setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"additionaloptions" ofType:@"png"]] forState:UIControlStateNormal];
        
        DuplicateinfoButton2.frame=CGRectMake(Dvaluex+20,400,Dwdth2+5, 40);
        [DuplicateinfoButton2 addTarget:self action:@selector(DuplicateinfoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
        
        [DuplicateinfoButton2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        DuplicateinfoButton2.tag=j+100;
        if (DuplicateinfoButton2.tag==102)
        {
            DuplicateinfoButton2.hidden=YES;
        }
        [DuplicateProductView addSubview:DuplicateinfoButton2];
        
        Dvaluex=Dvaluex+Dwdth2+15;
        
    }
    DuplicateSaveProductBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DuplicateSaveProductBtn.frame=CGRectMake(DuplicateProductfieldwidth+130, 480, 80, 30);
    [DuplicateSaveProductBtn addTarget:self action:@selector(SaveDuplicateProductData) forControlEvents:UIControlEventTouchUpInside];
    
    //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
    [DuplicateSaveProductBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //[DuplicateSaveProductBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
    [DuplicateSaveProductBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
    
    [DuplicateProductView addSubview:DuplicateSaveProductBtn];
    
    DuplicateCancelProductBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DuplicateCancelProductBtn.frame=CGRectMake(DuplicateProductfieldwidth+240, 480, 80,30);
    [DuplicateCancelProductBtn addTarget:self action:@selector(CancelDuplicateProductData) forControlEvents:UIControlEventTouchUpInside];
    [DuplicateCancelProductBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //[DuplicateCancelProductBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
    [DuplicateCancelProductBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
    
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [DuplicateProductView addSubview:DuplicateCancelProductBtn];
    [self DuplicateTotaltaxmethod];
    
    Deptstr=nil;
    itemnumber=nil;
    itemname=nil;
    des=nil;
    cost=nil;
    priceyoucharge=nil;
    pricewithtax=nil;
    instock=nil;
    vendorno=nil;
    taxstr=nil;
    tax1value=nil,tax2value=nil,tax3value=nil,bartaxvalue=nil;
    paddingview=nil,paddingview2=nil,paddingview3=nil,paddingview4=nil,paddingview5=nil;
    
}

- (IBAction)product_deleteButtonClicked:(id)sender
{
    UIButton *but =sender;
    // //NSLog(@"DeleteButton %d",but.tag);
    SelectedProduct=but.tag-1;
    deleteProductAlert=[[UIAlertView alloc]initWithTitle:@"Delete" message:@"Are you sure you want delete the Product" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel", nil];
    [deleteProductAlert show];
    
}
-(void) editcategoryViewremove
{
    NSArray * depertmentViewArray = EditCategoryView.subviews;
    for (int i = 0; i<[depertmentViewArray count]; i++) {
        UIView *vi =[depertmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addDepartmentViewArray = editCatpopupview.subviews;
    for (int i = 0; i<[addDepartmentViewArray count]; i++) {
        UIView *vi =[addDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditCategoryView removeFromSuperview],[editCatpopupview removeFromSuperview];

}
- (IBAction)category_editButtonClicked:(id)sender
{
    UIButton *but =sender;
    NSInteger  selectedrow=but.tag-1;
    // //NSLog(@"%d",selectedrow);
    editCatpopupview=[[UIView alloc]init];
    if (isLandScope) {
        editCatpopupview.frame=CGRectMake(0, 0, 1024, 768);
    }
    
    else{
        
        editCatpopupview.frame=CGRectMake(0, 0, 768, 1024);
    }
    [editCatpopupview setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:editCatpopupview];
    
    
    EditCategoryView=[[UIView alloc]init];
    
    EditCategoryView.frame=CGRectMake(50,100,editCatpopupview.frame.size.width-100,editCatpopupview.frame.size.height-200);
    [EditCategoryView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    
    EditCategoryView.layer.cornerRadius=8;
    [EditCategoryView.layer setBorderWidth:2.0];
    [EditCategoryView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
    [editCatpopupview addSubview:EditCategoryView];
    
    nameCat=[[NSString alloc]init];
    CatDes=[[NSString alloc]init];
    nameCat=[categorynamesArray objectAtIndex:selectedrow];
    CatDes= [categoryDesArray objectAtIndex:selectedrow];
    //NSString *selectedid=[categorynamesArray objectAtIndex:selectedrow];
   
    
    CGFloat changewidth=(EditCategoryView.frame.size.width)/2;
    
    CGFloat k=(changewidth/2)+20;
    
    ChnagecatIDlbl=[[UILabel alloc]init];
    ChnagecatIDlbl.frame=CGRectMake(k-40,150 ,200, 50);
    [ChnagecatIDlbl setText:@"Category ID"];
    [ChnagecatIDlbl setFont:[UIFont systemFontOfSize:25.0f]];
    [ChnagecatIDlbl setBackgroundColor:[UIColor clearColor]];
    [ChnagecatIDlbl setTextColor:[UIColor whiteColor]];
    [EditCategoryView addSubview:ChnagecatIDlbl];
    
    ChangecategoryidField=[[UITextField alloc] init];
    ChangecategoryidField.frame=CGRectMake(k+ChnagecatIDlbl.frame.size.width+30, 160, 200, 40);
    ChangecategoryidField.delegate=self;
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    ChangecategoryidField.leftView = paddingview;
    ChangecategoryidField.text=nameCat;
    ChangecategoryidField.leftViewMode = UITextFieldViewModeAlways;
    ChangecategoryidField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    //[ChangecategoryidField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [ChangecategoryidField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    
    
    [ChangecategoryidField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditCategoryView addSubview:ChangecategoryidField];
    
    ChangecatdesLbl=[[UILabel alloc]init];
    ChangecatdesLbl.frame=CGRectMake(k-40,250 ,250, 50);
    [ChangecatdesLbl setText:@"Category Description"];
    [ChangecatdesLbl setBackgroundColor:[UIColor clearColor]];
    [ChangecatdesLbl setFont:[UIFont systemFontOfSize:25.0f]];
    [ChangecatdesLbl setTextColor:[UIColor whiteColor]];
    [EditCategoryView addSubview:ChangecatdesLbl];
    
    ChengecatDesField=[[UITextView alloc] init];
    ChengecatDesField.frame=CGRectMake(k+ChnagecatIDlbl.frame.size.width+30, 230, 200, 100);
    ChengecatDesField.delegate=self;
    //    UIView *paddingview2=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    //    catDesField.leftView = paddingview2;
    //    catDesField.leftViewMode = UITextFieldViewModeAlways;
    [ChengecatDesField setAutocorrectionType:UITextAutocorrectionTypeNo];
    //[RateTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    // [catDesField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    // catDesField.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed: @"addinputtextfield.png"]];
    ChengecatDesField.text=CatDes;
    ChengecatDesField.layer.cornerRadius=8;
    //[catDesField setKeyboardType:UIKeyboardTypeNumberPad];
    //catDesField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    [EditCategoryView addSubview:ChengecatDesField];
    
    ChangesaveCategoryBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    ChangesaveCategoryBtn.frame=CGRectMake(k+ChnagecatIDlbl.frame.size.width-140, 360, 80, 30);
    [ChangesaveCategoryBtn addTarget:self action:@selector(SaveChangeCategorydata) forControlEvents:UIControlEventTouchUpInside];
    
    //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
    [ChangesaveCategoryBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //[ChangesaveCategoryBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
    [ChangesaveCategoryBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
    [EditCategoryView addSubview:ChangesaveCategoryBtn];
    
    ChangecancelcatBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    ChangecancelcatBtn.frame=CGRectMake(k+ChnagecatIDlbl.frame.size.width, 360, 80, 30);
    [ChangecancelcatBtn addTarget:self action:@selector(CancelChangeCatedorydataClicked) forControlEvents:UIControlEventTouchUpInside];
    [ChangecancelcatBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //[ChangecancelcatBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
    
    [ChangecancelcatBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    
    [EditCategoryView addSubview:ChangecancelcatBtn];
}
- (IBAction)category_deleteButtonClicked:(id)sender
{ UIButton *but =sender;
      // //NSLog(@"DeleteButton %d",but.tag);
    
    selectedcat=but.tag-1;
    deletecategoryAlert=[[UIAlertView alloc]initWithTitle:@"Delete" message:@"Are you sure you want delete the Category" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel", nil];
    [deletecategoryAlert show];
    
}
-(void) Editdepartmentviewremove
{
    NSArray * depertmentViewArray = EditDepartmentView.subviews;
    for (int i = 0; i<[depertmentViewArray count]; i++) {
        UIView *vi =[depertmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addDepartmentViewArray = editDepartmentpopup.subviews;
    for (int i = 0; i<[addDepartmentViewArray count]; i++) {
        UIView *vi =[addDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditDepartmentView removeFromSuperview],[editDepartmentpopup removeFromSuperview];
    
}
- (IBAction)Department_editButtonClicked:(id)sender{
    UIButton *but =sender;
      // //NSLog(@"DeleteButton %d",but.tag);
    
    NSInteger  selectedrow=but.tag-1;
    editDepartmentpopup=[[UIView alloc]init];
    if (isLandScope) {
        editDepartmentpopup.frame=CGRectMake(0, 0, 1024, 768);
    }
    
    else{
        
        editDepartmentpopup.frame=CGRectMake(0, 0, 768, 1024);
    }
    [editDepartmentpopup setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:editDepartmentpopup];
    
    
    EditDepartmentView=[[UIScrollView alloc]init];
    
    EditDepartmentView.frame=CGRectMake(50,100,editDepartmentpopup.frame.size.width-100,editDepartmentpopup.frame.size.height-200);
    [EditDepartmentView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    EditDepartmentView.contentSize=CGSizeMake(editDepartmentpopup.frame.size.width-100,editDepartmentpopup.frame.size.height+100);
    EditDepartmentView.layer.cornerRadius=8;
    [EditDepartmentView.layer setBorderWidth:2.0];
    [EditDepartmentView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
    [editDepartmentpopup addSubview:EditDepartmentView];
    
    desDept=[[NSString alloc]init];
    idDept=[[NSString alloc]init];
    nameDept=[[NSString alloc]init];
    idDept=[DeptCatIdsArray objectAtIndex:selectedrow];
    desDept= [DepartmentDesArray objectAtIndex:selectedrow];
    nameDept= [DepartmentNamesArray objectAtIndex:selectedrow];
    //NSString *selectedid=[DepartmentNamesArray objectAtIndex:selectedrow];
   
    NSString *taxstr=[depttaxesArray objectAtIndex:selectedrow];
    NSString *food=[deptfoodsArray objectAtIndex:selectedrow];
    
    NSString *printer,*time;
     NSString *querySQL = [NSString stringWithFormat:@"SELECT department_printer,department_print_time FROM department_printer_commands WHERE department_id='%@'",nameDept];
    NSMutableArray *printerArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:printerArray];
    //NSLog(@"printers %@",printerArray);
    
    deptprintersArray=[[NSMutableArray alloc]init];
    TimesArray=[[NSMutableArray alloc]init];
    @autoreleasepool {
        for (NSDictionary *myDict in printerArray)
        {
            printer=[myDict objectForKey:@"department_printer"];
            time=[myDict objectForKey:@"department_print_time"];
        }
    }
    
    
    NSArray *array2=[time componentsSeparatedByString:@":"];
    
    NSString *minit=[array2 objectAtIndex:0];
    NSString *sec=[array2 objectAtIndex:1];
    
    
    NSArray *array=[taxstr componentsSeparatedByString:@","];
    NSString *tax1value,*tax2value,*tax3value,*bartaxvalue;
    for (int i=0; i<[array count]; i++)
    {
        
        NSString  *tvalue=[array objectAtIndex:i];
        if ([tvalue isEqualToString:tax1Name])
        {
            tax1value=tvalue;
        }
        if ([tvalue isEqualToString:tax2Name])
        {
            tax2value=tvalue;
        }
        if ([tvalue isEqualToString:tax3Name])
        {
            tax3value=tvalue;
        }
        if ([tvalue isEqualToString:@"Bartax"])
        {
            bartaxvalue=tvalue;
        }
        
        
    }
    
    CGFloat deptlblwidth=(EditDepartmentView.frame.size.width)/2;
    CGFloat b=(deptlblwidth/2);
    
    Changedeptcatidlbl=[[UILabel alloc]init];
    Changedeptcatidlbl.frame=CGRectMake(b-100,60 ,350, 50);
    [Changedeptcatidlbl setText:@"Category for this Department"];
    [Changedeptcatidlbl setFont:[UIFont systemFontOfSize:25.0f]];
    [Changedeptcatidlbl setBackgroundColor:[UIColor clearColor]];
    [Changedeptcatidlbl setTextColor:[UIColor whiteColor]];
    [EditDepartmentView addSubview:Changedeptcatidlbl];
    
    
    ChangeCatforthisDeptBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    ChangeCatforthisDeptBtn.frame=CGRectMake(b+260, 70, 200, 40);
    [ChangeCatforthisDeptBtn addTarget:self action:@selector(ChangeCategoryforthisDept) forControlEvents:UIControlEventTouchUpInside];
    [ChangeCatforthisDeptBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[ChangeCatforthisDeptBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [ChangeCatforthisDeptBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [ChangeCatforthisDeptBtn setTitle:idDept forState:UIControlStateNormal];
    
    [EditDepartmentView addSubview:ChangeCatforthisDeptBtn];
    
    
    
    ChangecategorysListTable = [[UITableView alloc] initWithFrame:CGRectMake(b+260, 110,200,100) style:UITableViewStylePlain];
    ChangecategorysListTable.backgroundColor=[UIColor whiteColor];
    ChangecategorysListTable.delegate = self;
    ChangecategorysListTable.dataSource = self;
    ChangecategorysListTable.scrollEnabled = YES;
    ChangecategorysListTable.hidden=YES;
    [ChangecategorysListTable.layer setBorderWidth: 1.0];
    [ChangecategorysListTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditDepartmentView addSubview:ChangecategorysListTable];
    ChangedeptIDlbl=[[UILabel alloc]init];
    ChangedeptIDlbl.frame=CGRectMake(b-40,150 ,250, 50);
    [ChangedeptIDlbl setText:@"Department ID"];
    [ChangedeptIDlbl setFont:[UIFont systemFontOfSize:25.0f]];
    [ChangedeptIDlbl setBackgroundColor:[UIColor clearColor]];
    [ChangedeptIDlbl setTextColor:[UIColor whiteColor]];
    [EditDepartmentView addSubview:ChangedeptIDlbl];
    
    ChangeIDfield=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    ChangeIDfield.frame=CGRectMake(b+ChangedeptIDlbl.frame.size.width+10, 160, 200, 40);
    ChangeIDfield.delegate=self;
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    ChangeIDfield.leftView = paddingview;
    ChangeIDfield.text=nameDept;
    ChangeIDfield.leftViewMode = UITextFieldViewModeAlways;
    ChangeIDfield.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    [ChangeIDfield setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [ChangeIDfield setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    
    
    [ChangeIDfield setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditDepartmentView addSubview:ChangeIDfield];
    
    ChangedeptdesLbl=[[UILabel alloc]init];
    ChangedeptdesLbl.frame=CGRectMake(b-40,250 ,280, 50);
    [ChangedeptdesLbl setText:@"Department Description"];
    [ChangedeptdesLbl setBackgroundColor:[UIColor clearColor]];
    [ChangedeptdesLbl setFont:[UIFont systemFontOfSize:25.0f]];
    [ChangedeptdesLbl setTextColor:[UIColor whiteColor]];
    [EditDepartmentView addSubview:ChangedeptdesLbl];
    
    ChangedeptDestextView=[[UITextView alloc] init];
    ChangedeptDestextView.text=desDept;
    ChangedeptDestextView.frame=CGRectMake(b+ChangedeptIDlbl.frame.size.width+10, 230, 200, 100);
    ChangedeptDestextView.delegate=self;
    ChangedeptDestextView.font=[UIFont systemFontOfSize:14.0f];
    
    [ChangedeptDestextView setAutocorrectionType:UITextAutocorrectionTypeNo];
    
    ChangedeptDestextView.layer.cornerRadius=8;
    
    [EditDepartmentView addSubview:ChangedeptDestextView];
    
    ChangeDeptprinterlbl=[[UILabel alloc]init];
    ChangeDeptprinterlbl.frame=CGRectMake(b-40,350 ,280, 50);
    [ChangeDeptprinterlbl setText:@"Printer"];
    [ChangeDeptprinterlbl setBackgroundColor:[UIColor clearColor]];
    [ChangeDeptprinterlbl setFont:[UIFont systemFontOfSize:25.0f]];
    [ChangeDeptprinterlbl setTextColor:[UIColor whiteColor]];
    [EditDepartmentView addSubview:ChangeDeptprinterlbl];

    
    ChangeDeptprinterBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    ChangeDeptprinterBtn.frame=CGRectMake(b+260, 360, 200, 40);
    [ChangeDeptprinterBtn addTarget:self action:@selector(EditDeptprinterClicked) forControlEvents:UIControlEventTouchUpInside];
    [ChangeDeptprinterBtn setTitle:printer forState:UIControlStateNormal];
    [ChangeDeptprinterBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[ChangeDeptprinterBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [ChangeDeptprinterBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [EditDepartmentView addSubview:ChangeDeptprinterBtn];
    
    PrinterslistArray=[[NSMutableArray alloc]init];
    NSString *querySQL5 = [NSString stringWithFormat: @"SELECT print_id FROM printer"];
    NSMutableArray *printersArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL5 resultsArray:printersArray];
    
    if ([printersArray count]>0)
    {
        for (NSDictionary *Dict in printersArray)
        {
            [PrinterslistArray addObject:[Dict objectForKey:@"print_id"]];
        }
    }
    
    
    ChangePrinterslistTable = [[UITableView alloc] initWithFrame:CGRectMake(b+260, 260,200,100) style:UITableViewStylePlain];
    ChangePrinterslistTable.backgroundColor=[UIColor whiteColor];
    ChangePrinterslistTable.delegate = self;
    ChangePrinterslistTable.dataSource = self;
    ChangePrinterslistTable.scrollEnabled = YES;
    ChangePrinterslistTable.hidden=YES;
    [ChangePrinterslistTable.layer setBorderWidth: 1.0];
    [ChangePrinterslistTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditDepartmentView addSubview:ChangePrinterslistTable];
    
    ChangeDeptFoodstampablelbl=[[UILabel alloc]init];
    ChangeDeptFoodstampablelbl.frame=CGRectMake(b-40,400 ,280, 50);
    [ChangeDeptFoodstampablelbl setText:@"Foddstampable"];
    [ChangeDeptFoodstampablelbl setBackgroundColor:[UIColor clearColor]];
    [ChangeDeptFoodstampablelbl setFont:[UIFont systemFontOfSize:25.0f]];
    [ChangeDeptFoodstampablelbl setTextColor:[UIColor whiteColor]];
    [EditDepartmentView addSubview:ChangeDeptFoodstampablelbl];
    
    ChangeDeptfoodstampleBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    ChangeDeptfoodstampleBtn.frame=CGRectMake(b+260, 410, 30, 30);
    [ChangeDeptfoodstampleBtn addTarget:self action:@selector(EditFoodstampableClicked) forControlEvents:UIControlEventTouchUpInside];
    [ChangeDeptfoodstampleBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[ChangeDeptfoodstampleBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[ChangeDeptfoodstampleBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [ChangeDeptfoodstampleBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [ChangeDeptfoodstampleBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [EditDepartmentView addSubview:ChangeDeptfoodstampleBtn];
    
    
    ChangeDeptax1Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    ChangeDeptax1Btn.frame=CGRectMake(b-60,460,30, 30);
    [ChangeDeptax1Btn addTarget:self action:@selector(EditDeptTax1Clicked) forControlEvents:UIControlEventTouchUpInside];
    [ChangeDeptax1Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[ChangeDeptax1Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[ChangeDeptax1Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    
    [ChangeDeptax1Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [ChangeDeptax1Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [EditDepartmentView addSubview:ChangeDeptax1Btn];
    
    ChangeDeptax1lbl=[[UILabel alloc] init];
    ChangeDeptax1lbl.frame=CGRectMake(b+35-60,455,50, 40);
    [ChangeDeptax1lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [ChangeDeptax1lbl setBackgroundColor:[UIColor clearColor]];
    [ChangeDeptax1lbl setTextColor:[UIColor whiteColor]];
    ChangeDeptax1Btn.selected=YES;
    [ChangeDeptax1lbl setText:tax1Name];
    
    [ChangeDeptax1lbl setTextAlignment:NSTextAlignmentLeft];
    [EditDepartmentView addSubview:ChangeDeptax1lbl];
    
    
    ChangeDeptax2Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    ChangeDeptax2Btn.frame=CGRectMake(b+75+ChangeDeptax1lbl.frame.size.width-40,460,30, 30);
    [ChangeDeptax2Btn addTarget:self action:@selector(EditDeptTax2Clikced) forControlEvents:UIControlEventTouchUpInside];
    [ChangeDeptax2Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[ChangeDeptax2Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[ChangeDeptax2Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    
    [ChangeDeptax2Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [ChangeDeptax2Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [EditDepartmentView addSubview:ChangeDeptax2Btn];
    
    ChangeDeptax2lbl=[[UILabel alloc] init];
    ChangeDeptax2lbl.frame=CGRectMake(b+65+ChangeDeptax1lbl.frame.size.width+45-40,455,50, 40);
    [ChangeDeptax2lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [ChangeDeptax2lbl setBackgroundColor:[UIColor clearColor]];
    [ChangeDeptax2lbl setTextColor:[UIColor whiteColor]];
    
    [ChangeDeptax2lbl setText:tax2Name];
    
    [ChangeDeptax2lbl setTextAlignment:NSTextAlignmentLeft];
    [EditDepartmentView addSubview:ChangeDeptax2lbl];
    
    ChangeDeptax3Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    ChangeDeptax3Btn.frame=CGRectMake(b+75+ChangeDeptax1lbl.frame.size.width+45-20+ChangeDeptax2lbl.frame.size.width,460,30, 30);
    [ChangeDeptax3Btn addTarget:self action:@selector(EditDeptTax3Clicked) forControlEvents:UIControlEventTouchUpInside];
    [ChangeDeptax3Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[ChangeDeptax3Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[ChangeDeptax3Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [ChangeDeptax3Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [ChangeDeptax3Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [EditDepartmentView addSubview:ChangeDeptax3Btn];
    
    ChangeDeptax3lbl=[[UILabel alloc] init];
    ChangeDeptax3lbl.frame=CGRectMake(b+65+ChangeDeptax1lbl.frame.size.width+45-20+ChangeDeptax2lbl.frame.size.width+45,455,50, 40);
    [ChangeDeptax3lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [ChangeDeptax3lbl setBackgroundColor:[UIColor clearColor]];
    [ChangeDeptax3lbl setTextColor:[UIColor whiteColor]];
    
    [ChangeDeptax3lbl setText:tax3Name];
    
    [ChangeDeptax3lbl setTextAlignment:NSTextAlignmentLeft];
    [EditDepartmentView addSubview:ChangeDeptax3lbl];
    
    ChangeDepBarTaxBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    ChangeDepBarTaxBtn.frame=CGRectMake(b+75+ChangeDeptax1lbl.frame.size.width+45+ChangeDeptax2lbl.frame.size.width+45+ChangeDeptax3lbl.frame.size.width,460,30, 30);
    [ChangeDepBarTaxBtn addTarget:self action:@selector(EditDeptBarBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [ChangeDepBarTaxBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[ChangeDepBarTaxBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    // [ChangeDepBarTaxBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    
    [ChangeDepBarTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [ChangeDepBarTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    [EditDepartmentView addSubview:ChangeDepBarTaxBtn];
    
    ChangeDepbartaxlbl=[[UILabel alloc] init];
    ChangeDepbartaxlbl.frame=CGRectMake(b+65+ChangeDeptax1lbl.frame.size.width+45+ChangeDeptax2lbl.frame.size.width+45+ChangeDeptax3lbl.frame.size.width+45,455,80, 40);
    [ChangeDepbartaxlbl setFont:[UIFont systemFontOfSize:18.0f]];
    [ChangeDepbartaxlbl setBackgroundColor:[UIColor clearColor]];
    [ChangeDepbartaxlbl setTextColor:[UIColor whiteColor]];
    [ChangeDepbartaxlbl setText:@"Bartax"];
    [ChangeDepbartaxlbl setTextAlignment:NSTextAlignmentLeft];
    [EditDepartmentView addSubview:ChangeDepbartaxlbl];
    
    if ([food isEqualToString:@"YES"])
    {
        ChangeDeptfoodstampleBtn.selected=YES;
        EditDeptfoodstampable=@"YES";
    }
    else
    {
        ChangeDeptfoodstampleBtn.selected=NO;
        EditDeptfoodstampable=@"NO";
    }
    if ([tax1value isEqualToString:tax1Name])
    {
        ChangeDeptax1Btn.selected=YES;
        
    }
    else
    {
        ChangeDeptax1Btn.selected=NO;
    }
    if ([tax2value isEqualToString:tax2Name])
    {
        ChangeDeptax2Btn.selected=YES;
        
    }
    else
    {
        ChangeDeptax2Btn.selected=NO;
    }
    if ([tax3value isEqualToString:tax3Name])
    {
        ChangeDeptax3Btn.selected=YES;
        
    }
    else
    {
        ChangeDeptax3Btn.selected=NO;
    }
    if ([bartaxvalue isEqualToString:@"Bartax"])
    {
        ChangeDepBarTaxBtn.selected=YES;
        
    }
    else
    {
        ChangeDepBarTaxBtn.selected=NO;
    }
    [self EditDeptTotaltaxmethod];
    
    ChangeTimeForDeptlbl=[[UILabel alloc]init];
    ChangeTimeForDeptlbl.frame=CGRectMake(b-100,520 ,350, 50);
    [ChangeTimeForDeptlbl setText:@"Time for Department Printer"];
    [ChangeTimeForDeptlbl setFont:[UIFont systemFontOfSize:25.0f]];
    [ChangeTimeForDeptlbl setBackgroundColor:[UIColor clearColor]];
    [ChangeTimeForDeptlbl setTextColor:[UIColor whiteColor]];
    [EditDepartmentView addSubview:ChangeTimeForDeptlbl];
    
    ChangeMinitBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    ChangeMinitBtn.frame=CGRectMake(b+260,520, 100, 40);
    [ChangeMinitBtn addTarget:self action:@selector(EditminitsBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [ChangeMinitBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[ChangeMinitBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    
    [ChangeMinitBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    
    [ChangeMinitBtn setTitle:minit forState:UIControlStateNormal];
    [EditDepartmentView addSubview:ChangeMinitBtn];
    
    ChangeMinitslistTable = [[UITableView alloc] initWithFrame:CGRectMake(b+260, 560,100,100) style:UITableViewStylePlain];
    ChangeMinitslistTable.backgroundColor=[UIColor whiteColor];
    ChangeMinitslistTable.delegate = self;
    ChangeMinitslistTable.dataSource = self;
    ChangeMinitslistTable.scrollEnabled = YES;
    ChangeMinitslistTable.hidden=YES;
    [ChangeMinitslistTable.layer setBorderWidth: 1.0];
    [ChangeMinitslistTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditDepartmentView addSubview:ChangeMinitslistTable];
    
    ChangeSecsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    ChangeSecsBtn.frame=CGRectMake(b+370, 520, 100, 40);
    [ChangeSecsBtn addTarget:self action:@selector(EditSecsBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [ChangeSecsBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[ChangeSecsBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    
    [ChangeSecsBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [ChangeSecsBtn setTitle:sec forState:UIControlStateNormal];
    [EditDepartmentView addSubview:ChangeSecsBtn];
    
    ChangeSecslistTable = [[UITableView alloc] initWithFrame:CGRectMake(b+370, 560, 100, 100) style:UITableViewStylePlain];
    ChangeSecslistTable.backgroundColor=[UIColor whiteColor];
    ChangeSecslistTable.delegate = self;
    ChangeSecslistTable.dataSource = self;
    ChangeSecslistTable.scrollEnabled = YES;
    ChangeSecslistTable.hidden=YES;
    [ChangeSecslistTable.layer setBorderWidth: 1.0];
    [ChangeSecslistTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditDepartmentView addSubview:ChangeSecslistTable];
    
    
    ChangesavedeptBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    ChangesavedeptBtn.frame=CGRectMake(b+ChangedeptIDlbl.frame.size.width-180, 620, 80, 30);
    [ChangesavedeptBtn addTarget:self action:@selector(SaveChangeDeptData) forControlEvents:UIControlEventTouchUpInside];
    
    //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
    [ChangesavedeptBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //[ChangesavedeptBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
    [ChangesavedeptBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
    [EditDepartmentView addSubview:ChangesavedeptBtn];
    
    Changecanceldeptbtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    Changecanceldeptbtn.frame=CGRectMake(b+ChangedeptIDlbl.frame.size.width-10, 620, 80, 30);
    [Changecanceldeptbtn addTarget:self action:@selector(CancelChangeDeptData) forControlEvents:UIControlEventTouchUpInside];
    [Changecanceldeptbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    // [Changecanceldeptbtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
    [Changecanceldeptbtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
    
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [EditDepartmentView addSubview:Changecanceldeptbtn];
    
}
-(void) duplicatedepartmentViewremove
{
    
    NSArray * depertmentViewArray = DuplicateDepartmentView.subviews;
    for (int i = 0; i<[depertmentViewArray count]; i++) {
        UIView *vi =[depertmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addDepartmentViewArray = DuplicateDepartmentpopup.subviews;
    for (int i = 0; i<[addDepartmentViewArray count]; i++) {
        UIView *vi =[addDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [DuplicateDepartmentView removeFromSuperview],[DuplicateDepartmentpopup removeFromSuperview];
}
- (IBAction)Department_duplicateButtonClicked:(id)sender
{
    UIButton *but =sender;
      // //NSLog(@"DeleteButton %d",but.tag);
    
    NSInteger  selectedrow=but.tag-1;
    DuplicateDepartmentpopup=[[UIView alloc]init];
    if (isLandScope) {
        DuplicateDepartmentpopup.frame=CGRectMake(0, 0, 1024, 768);
    }
    
    else{
        
        DuplicateDepartmentpopup.frame=CGRectMake(0, 0, 768, 1024);
    }
    [DuplicateDepartmentpopup setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:DuplicateDepartmentpopup];
    
    DuplicateDepartmentView=[[UIScrollView alloc]init];
    
    DuplicateDepartmentView.frame=CGRectMake(50,100,DuplicateDepartmentpopup.frame.size.width-100,DuplicateDepartmentpopup.frame.size.height-200);
    [DuplicateDepartmentView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    DuplicateDepartmentView.contentSize=CGSizeMake(DuplicateDepartmentpopup.frame.size.width-100,DuplicateDepartmentpopup.frame.size.height+200);
    [DuplicateDepartmentView.layer setBorderWidth:2.0];
    [DuplicateDepartmentView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
    DuplicateDepartmentView.layer.cornerRadius=8;
    
    [DuplicateDepartmentpopup addSubview:DuplicateDepartmentView];
    
    
  
    idDept=[DeptCatIdsArray objectAtIndex:selectedrow];
    desDept= [DepartmentDesArray objectAtIndex:selectedrow];
    nameDept= [DepartmentNamesArray objectAtIndex:selectedrow];
    
    NSString *taxstr=[depttaxesArray objectAtIndex:selectedrow];
    NSString *food=[deptfoodsArray objectAtIndex:selectedrow];
    
   
    NSString *printer,*time;
    NSString *querySQL = [NSString stringWithFormat: @"SELECT department_printer,department_print_time FROM department_printer_commands WHERE department_id='%@'",nameDept];
    NSMutableArray *printerArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:printerArray];

    
    deptprintersArray=[[NSMutableArray alloc]init];
    TimesArray=[[NSMutableArray alloc]init];
    for (NSDictionary *myDict in printerArray)
    {
        printer=[myDict objectForKey:@"department_printer"];
        time=[myDict objectForKey:@"department_print_time"];
    }
    
    NSArray *array2=[time componentsSeparatedByString:@":"];
    
    NSString *minit=[array2 objectAtIndex:0];
    NSString *sec=[array2 objectAtIndex:1];
    
    NSArray *array=[taxstr componentsSeparatedByString:@","];
    NSString *tax1value,*tax2value,*tax3value,*bartaxvalue;
    for (int i=0; i<[array count]; i++)
    {
        
        NSString  *tvalue=[array objectAtIndex:i];
        if ([tvalue isEqualToString:tax1Name])
        {
            tax1value=tvalue;
        }
        if ([tvalue isEqualToString:tax2Name])
        {
            tax2value=tvalue;
        }
        if ([tvalue isEqualToString:tax3Name])
        {
            tax3value=tvalue;
        }
        if ([tvalue isEqualToString:@"Bartax"])
        {
            bartaxvalue=tvalue;
        }
        
        
    }
    
    
    CGFloat Dubdeptlblwidth=(DuplicateDepartmentView.frame.size.width)/2;
    CGFloat dub=(Dubdeptlblwidth/2);
    
    Duplicatedeptcatidlbl=[[UILabel alloc]init];
    Duplicatedeptcatidlbl.frame=CGRectMake(dub-100,60 ,350, 50);
    [Duplicatedeptcatidlbl setText:@"Category for this Department"];
    [Duplicatedeptcatidlbl setFont:[UIFont systemFontOfSize:25.0f]];
    [Duplicatedeptcatidlbl setBackgroundColor:[UIColor clearColor]];
    [Duplicatedeptcatidlbl setTextColor:[UIColor whiteColor]];
    [DuplicateDepartmentView addSubview:Duplicatedeptcatidlbl];
    
    
    DuplicateCatforthisDeptBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DuplicateCatforthisDeptBtn.frame=CGRectMake(dub+260, 70, 200, 40);
    [DuplicateCatforthisDeptBtn addTarget:self action:@selector(DuplicateCategoryforthisDept) forControlEvents:UIControlEventTouchUpInside];
    [DuplicateCatforthisDeptBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DuplicateCatforthisDeptBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    
    [DuplicateCatforthisDeptBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [DuplicateCatforthisDeptBtn setTitle:idDept forState:UIControlStateNormal];
    
    [DuplicateDepartmentView addSubview:DuplicateCatforthisDeptBtn];
    
    
    
    DuplicatecategorysListTable = [[UITableView alloc] initWithFrame:CGRectMake(dub+260, 110,200,100) style:UITableViewStylePlain];
    DuplicatecategorysListTable.backgroundColor=[UIColor whiteColor];
    DuplicatecategorysListTable.delegate = self;
    DuplicatecategorysListTable.dataSource = self;
    DuplicatecategorysListTable.scrollEnabled = YES;
    DuplicatecategorysListTable.hidden=YES;
    [DuplicatecategorysListTable.layer setBorderWidth: 1.0];
    [DuplicatecategorysListTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [DuplicateDepartmentView addSubview:DuplicatecategorysListTable];
    
    DuplicatedeptIDlbl=[[UILabel alloc]init];
    DuplicatedeptIDlbl.frame=CGRectMake(dub-40,150 ,250, 50);
    [DuplicatedeptIDlbl setText:@"Department ID"];
    [DuplicatedeptIDlbl setFont:[UIFont systemFontOfSize:25.0f]];
    [DuplicatedeptIDlbl setBackgroundColor:[UIColor clearColor]];
    [DuplicatedeptIDlbl setTextColor:[UIColor whiteColor]];
    [DuplicateDepartmentView addSubview:DuplicatedeptIDlbl];
    
    DuplicateIDfield=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    DuplicateIDfield.frame=CGRectMake(dub+DuplicatedeptIDlbl.frame.size.width+10, 160, 200, 40);
    DuplicateIDfield.delegate=self;
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    DuplicateIDfield.leftView = paddingview;
    DuplicateIDfield.text=nameDept;
    DuplicateIDfield.leftViewMode = UITextFieldViewModeAlways;
    DuplicateIDfield.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    //[DuplicateIDfield setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [DuplicateIDfield setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    
    
    [DuplicateIDfield setAutocorrectionType:UITextAutocorrectionTypeNo];
    [DuplicateDepartmentView addSubview:DuplicateIDfield];
    
    DuplicatedeptdesLbl=[[UILabel alloc]init];
    DuplicatedeptdesLbl.frame=CGRectMake(dub-40,250 ,280, 50);
    [DuplicatedeptdesLbl setText:@"Department Description"];
    [DuplicatedeptdesLbl setBackgroundColor:[UIColor clearColor]];
    [DuplicatedeptdesLbl setFont:[UIFont systemFontOfSize:25.0f]];
    [DuplicatedeptdesLbl setTextColor:[UIColor whiteColor]];
    [DuplicateDepartmentView addSubview:DuplicatedeptdesLbl];
    
    DuplicatedeptDestextView=[[UITextView alloc] init];
    DuplicatedeptDestextView.text=desDept;
    DuplicatedeptDestextView.frame=CGRectMake(dub+DuplicatedeptIDlbl.frame.size.width+10, 230, 200, 100);
    DuplicatedeptDestextView.delegate=self;
    DuplicatedeptDestextView.font=[UIFont systemFontOfSize:14.0f];
    
    [DuplicatedeptDestextView setAutocorrectionType:UITextAutocorrectionTypeNo];
    
    DuplicatedeptDestextView.layer.cornerRadius=8;
    
    [DuplicateDepartmentView addSubview:DuplicatedeptDestextView];
    DuplicateDeptprinterlbl=[[UILabel alloc]init];
    DuplicateDeptprinterlbl.frame=CGRectMake(dub-40,350 ,280, 50);
    [DuplicateDeptprinterlbl setText:@"Printer"];
    [DuplicateDeptprinterlbl setBackgroundColor:[UIColor clearColor]];
    [DuplicateDeptprinterlbl setFont:[UIFont systemFontOfSize:25.0f]];
    [DuplicateDeptprinterlbl setTextColor:[UIColor whiteColor]];
    [DuplicateDepartmentView addSubview:DuplicateDeptprinterlbl];
    
    
    
    DuplicateDeptprinterBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DuplicateDeptprinterBtn.frame=CGRectMake(dub+260, 360, 200, 40);
    [DuplicateDeptprinterBtn addTarget:self action:@selector(DuplicateDeptprinterClicked) forControlEvents:UIControlEventTouchUpInside];
    [DuplicateDeptprinterBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DuplicateDeptprinterBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [DuplicateDeptprinterBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    
    [DuplicateDeptprinterBtn setTitle:printer forState:UIControlStateNormal];
    [DuplicateDepartmentView addSubview:DuplicateDeptprinterBtn];
    
    PrinterslistArray=[[NSMutableArray alloc]init];
    NSString *querySQL5 = [NSString stringWithFormat: @"SELECT print_id FROM printer"];
    NSMutableArray *printersArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL5 resultsArray:printersArray];
    
    if ([printersArray count]>0)
    {
        for (NSDictionary *Dict in printersArray)
        {
            
            [PrinterslistArray addObject:[Dict objectForKey:@"print_id"]];
        }
    }
    
    DuplicatePrinterslistTable = [[UITableView alloc] initWithFrame:CGRectMake(dub+260, 260,200,100) style:UITableViewStylePlain];
    DuplicatePrinterslistTable.backgroundColor=[UIColor whiteColor];
    DuplicatePrinterslistTable.delegate = self;
    DuplicatePrinterslistTable.dataSource = self;
    DuplicatePrinterslistTable.scrollEnabled = YES;
    DuplicatePrinterslistTable.hidden=YES;
    [DuplicatePrinterslistTable.layer setBorderWidth: 1.0];
    [DuplicatePrinterslistTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [DuplicateDepartmentView addSubview:DuplicatePrinterslistTable];
    
    DuplicateDeptFoodstampablelbl=[[UILabel alloc]init];
    DuplicateDeptFoodstampablelbl.frame=CGRectMake(dub-40,400 ,280, 50);
    [DuplicateDeptFoodstampablelbl setText:@"Foddstampable"];
    [DuplicateDeptFoodstampablelbl setBackgroundColor:[UIColor clearColor]];
    [DuplicateDeptFoodstampablelbl setFont:[UIFont systemFontOfSize:25.0f]];
    [DuplicateDeptFoodstampablelbl setTextColor:[UIColor whiteColor]];
    [DuplicateDepartmentView addSubview:DuplicateDeptFoodstampablelbl];
    
    DuplicateDeptfoodstampleBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DuplicateDeptfoodstampleBtn.frame=CGRectMake(dub+260, 410, 30, 30);
    [DuplicateDeptfoodstampleBtn addTarget:self action:@selector(DuplicateFoodstampableClicked) forControlEvents:UIControlEventTouchUpInside];
    [DuplicateDeptfoodstampleBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DuplicateDeptfoodstampleBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[DuplicateDeptfoodstampleBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    
    [DuplicateDeptfoodstampleBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [DuplicateDeptfoodstampleBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [DuplicateDepartmentView addSubview:DuplicateDeptfoodstampleBtn];
    
    
    DuplicateDeptax1Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DuplicateDeptax1Btn.frame=CGRectMake(dub-60,460,30, 30);
    [DuplicateDeptax1Btn addTarget:self action:@selector(DuplicateDeptTax1Clicked) forControlEvents:UIControlEventTouchUpInside];
    [DuplicateDeptax1Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DuplicateDeptax1Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[DuplicateDeptax1Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [DuplicateDeptax1Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [DuplicateDeptax1Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [DuplicateDepartmentView addSubview:DuplicateDeptax1Btn];
    
    DuplicateDeptax1lbl=[[UILabel alloc] init];
    DuplicateDeptax1lbl.frame=CGRectMake(dub+35-60,455,50, 40);
    [DuplicateDeptax1lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [DuplicateDeptax1lbl setBackgroundColor:[UIColor clearColor]];
    [DuplicateDeptax1lbl setTextColor:[UIColor whiteColor]];
    DuplicateDeptax1Btn.selected=YES;
    [DuplicateDeptax1lbl setText:tax1Name];
    
    [DuplicateDeptax1lbl setTextAlignment:NSTextAlignmentLeft];
    [DuplicateDepartmentView addSubview:DuplicateDeptax1lbl];
    
    
    DuplicateDeptax2Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DuplicateDeptax2Btn.frame=CGRectMake(dub+75+DuplicateDeptax1lbl.frame.size.width-40,460,30, 30);
    [DuplicateDeptax2Btn addTarget:self action:@selector(DuplicateDeptTax2Clikced) forControlEvents:UIControlEventTouchUpInside];
    [DuplicateDeptax2Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    // [DuplicateDeptax2Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[DuplicateDeptax2Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    
    [DuplicateDeptax2Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [DuplicateDeptax2Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    [DuplicateDepartmentView addSubview:DuplicateDeptax2Btn];
    
    DuplicateDeptax2lbl=[[UILabel alloc] init];
    DuplicateDeptax2lbl.frame=CGRectMake(dub+65+DuplicateDeptax1lbl.frame.size.width+45-40,455,50, 40);
    [DuplicateDeptax2lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [DuplicateDeptax2lbl setBackgroundColor:[UIColor clearColor]];
    [DuplicateDeptax2lbl setTextColor:[UIColor whiteColor]];
    
    [DuplicateDeptax2lbl setText:tax2Name];
    
    [DuplicateDeptax2lbl setTextAlignment:NSTextAlignmentLeft];
    [DuplicateDepartmentView addSubview:DuplicateDeptax2lbl];
    
    DuplicateDeptax3Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DuplicateDeptax3Btn.frame=CGRectMake(dub+75+DuplicateDeptax1lbl.frame.size.width+45-20+DuplicateDeptax2lbl.frame.size.width,460,30, 30);
    [DuplicateDeptax3Btn addTarget:self action:@selector(DuplicateDeptTax3Clicked) forControlEvents:UIControlEventTouchUpInside];
    [DuplicateDeptax3Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    // [DuplicateDeptax3Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[DuplicateDeptax3Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    
    [DuplicateDeptax3Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [DuplicateDeptax3Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [DuplicateDepartmentView addSubview:DuplicateDeptax3Btn];
    
    DuplicateDeptax3lbl=[[UILabel alloc] init];
    DuplicateDeptax3lbl.frame=CGRectMake(dub+65+DuplicateDeptax1lbl.frame.size.width+45-20+DuplicateDeptax2lbl.frame.size.width+45,455,50, 40);
    [DuplicateDeptax3lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [DuplicateDeptax3lbl setBackgroundColor:[UIColor clearColor]];
    [DuplicateDeptax3lbl setTextColor:[UIColor whiteColor]];
    
    [DuplicateDeptax3lbl setText:tax3Name];
    
    [DuplicateDeptax3lbl setTextAlignment:NSTextAlignmentLeft];
    [DuplicateDepartmentView addSubview:DuplicateDeptax3lbl];
    
    DuplicateDepBarTaxBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DuplicateDepBarTaxBtn.frame=CGRectMake(dub+75+DuplicateDeptax1lbl.frame.size.width+45+DuplicateDeptax2lbl.frame.size.width+45+DuplicateDeptax3lbl.frame.size.width,460,30, 30);
    [DuplicateDepBarTaxBtn addTarget:self action:@selector(DuplicateDeptBarBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [DuplicateDepBarTaxBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DuplicateDepBarTaxBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    // [DuplicateDepBarTaxBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    
    [DuplicateDepBarTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    [DuplicateDepBarTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    [DuplicateDepartmentView addSubview:DuplicateDepBarTaxBtn];
    
    DuplicateDepbartaxlbl=[[UILabel alloc] init];
    DuplicateDepbartaxlbl.frame=CGRectMake(dub+65+DuplicateDeptax1lbl.frame.size.width+45+DuplicateDeptax2lbl.frame.size.width+45+Deptax3lbl.frame.size.width+45,455,80, 40);
    [DuplicateDepbartaxlbl setFont:[UIFont systemFontOfSize:18.0f]];
    [DuplicateDepbartaxlbl setBackgroundColor:[UIColor clearColor]];
    [DuplicateDepbartaxlbl setTextColor:[UIColor whiteColor]];
    [DuplicateDepbartaxlbl setText:@"Bartax"];
    [DuplicateDepbartaxlbl setTextAlignment:NSTextAlignmentLeft];
    [DuplicateDepartmentView addSubview:DuplicateDepbartaxlbl];
    
    
    if ([food isEqualToString:@"yes"])
    {
        DuplicateDeptfoodstampleBtn.selected=YES;
        EditDeptfoodstampable=@"yes";
    }
    else
    {
        DuplicateDeptfoodstampleBtn.selected=NO;
        EditDeptfoodstampable=@"no";
    }
    if ([tax1value isEqualToString:tax1Name])
    {
        DuplicateDeptax1Btn.selected=YES;
        
    }
    else
    {
        DuplicateDeptax1Btn.selected=NO;
    }
    if ([tax2value isEqualToString:tax2Name])
    {
        DuplicateDeptax2Btn.selected=YES;
        
    }
    else
    {
        DuplicateDeptax2Btn.selected=NO;
    }
    if ([tax3value isEqualToString:tax3Name])
    {
        DuplicateDeptax3Btn.selected=YES;
        
    }
    else
    {
        DuplicateDeptax3Btn.selected=NO;
    }
    if ([bartaxvalue isEqualToString:@"Bartax"])
    {
        DuplicateDepBarTaxBtn.selected=YES;
        
    }
    else
    {
        DuplicateDepBarTaxBtn.selected=NO;
    }
    [self DuplicateDeptTotaltaxmethod];
    
    
    DuplicateTimeForDeptlbl=[[UILabel alloc]init];
    DuplicateTimeForDeptlbl.frame=CGRectMake(dub-100,520 ,350, 50);
    [DuplicateTimeForDeptlbl setText:@"Time for Department Printer"];
    [DuplicateTimeForDeptlbl setFont:[UIFont systemFontOfSize:25.0f]];
    [DuplicateTimeForDeptlbl setBackgroundColor:[UIColor clearColor]];
    [DuplicateTimeForDeptlbl setTextColor:[UIColor whiteColor]];
    [DuplicateDepartmentView addSubview:DuplicateTimeForDeptlbl];
    
    DuplicateMinitBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DuplicateMinitBtn.frame=CGRectMake(dub+260,520, 100, 40);
    [DuplicateMinitBtn addTarget:self action:@selector(DuplicateminitsBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [DuplicateMinitBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DuplicateMinitBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [DuplicateMinitBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    
    [DuplicateMinitBtn setTitle:minit forState:UIControlStateNormal];
    [DuplicateDepartmentView addSubview:DuplicateMinitBtn];
    
    DuplicateMinitslistTable = [[UITableView alloc] initWithFrame:CGRectMake(dub+260, 560,100,100) style:UITableViewStylePlain];
    DuplicateMinitslistTable.backgroundColor=[UIColor whiteColor];
    DuplicateMinitslistTable.delegate = self;
    DuplicateMinitslistTable.dataSource = self;
    DuplicateMinitslistTable.scrollEnabled = YES;
    DuplicateMinitslistTable.hidden=YES;
    [DuplicateMinitslistTable.layer setBorderWidth: 1.0];
    [DuplicateMinitslistTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [DuplicateDepartmentView addSubview:DuplicateMinitslistTable];
    
    DuplicateSecsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DuplicateSecsBtn.frame=CGRectMake(dub+370, 520, 100, 40);
    [DuplicateSecsBtn addTarget:self action:@selector(DuplicateSecsBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [DuplicateSecsBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DuplicateSecsBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [DuplicateSecsBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [DuplicateSecsBtn setTitle:sec forState:UIControlStateNormal];
    [DuplicateDepartmentView addSubview:DuplicateSecsBtn];
    
    DuplicateSecslistTable = [[UITableView alloc] initWithFrame:CGRectMake(dub+370, 560, 100, 100) style:UITableViewStylePlain];
    DuplicateSecslistTable.backgroundColor=[UIColor whiteColor];
    DuplicateSecslistTable.delegate = self;
    DuplicateSecslistTable.dataSource = self;
    DuplicateSecslistTable.scrollEnabled = YES;
    DuplicateSecslistTable.hidden=YES;
    [DuplicateSecslistTable.layer setBorderWidth: 1.0];
    [DuplicateSecslistTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [DuplicateDepartmentView addSubview:DuplicateSecslistTable];
    DuplicatesavedeptBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DuplicatesavedeptBtn.frame=CGRectMake(dub+DuplicatedeptIDlbl.frame.size.width-180,620, 80, 30);
    [DuplicatesavedeptBtn addTarget:self action:@selector(SaveDuplicateDeptData) forControlEvents:UIControlEventTouchUpInside];
    
    //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
    [DuplicatesavedeptBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //[DuplicatesavedeptBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
    [DuplicatesavedeptBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
    
    [DuplicateDepartmentView addSubview:DuplicatesavedeptBtn];
    
    Duplicatecanceldeptbtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    Duplicatecanceldeptbtn.frame=CGRectMake(dub+DuplicatedeptIDlbl.frame.size.width-10, 620, 80, 30);
    [Duplicatecanceldeptbtn addTarget:self action:@selector(CancelDuplicateDeptData) forControlEvents:UIControlEventTouchUpInside];
    [Duplicatecanceldeptbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //[Duplicatecanceldeptbtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
    
    [Duplicatecanceldeptbtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [DuplicateDepartmentView addSubview:Duplicatecanceldeptbtn];
}
- (IBAction)Department_deleteButtonClicked:(id)sender
{
    UIButton *but =sender;
      // //NSLog(@"DeleteButton %d",but.tag);

    selectedcat=but.tag-1;
    deleteDeptAlert=[[UIAlertView alloc]initWithTitle:@"Delete" message:@"Are you sure you want delete the Department" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel", nil];
    [deleteDeptAlert show];
}


- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if (textField == ItemNumberField) {
		[textField resignFirstResponder];
		[ItemNameField becomeFirstResponder];
	}
	else if (textField == ItemNameField) {
		[textField resignFirstResponder];
        [CostField becomeFirstResponder];
    }
    else if (textField == CostField) {
		[textField resignFirstResponder];
        [PriceyouChargeField becomeFirstResponder];
    }
    else if (textField == PriceyouChargeField) {
		[textField resignFirstResponder];
        [InStockField becomeFirstResponder];
    }
    else if (textField == InStockField) {
		[textField resignFirstResponder];
        
    }
    BOOL isDone = YES;
	
	if (isDone) {
		[self finishedSearching];
		return YES;
	} else {
		return NO;
	}
    return YES;
   
    [textField resignFirstResponder];
    return YES;
}
-(void)showTime
{
    
    NSDate *aDate = [NSDate date];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterShortStyle];
    [formatter setTimeStyle:NSDateFormatterNoStyle];
    [formatter setDateFormat:@"HH:mm:ss"];
    NSString *datestr;
    datestr=[formatter stringFromDate:aDate];
    Timelbl.text=datestr;
    // Timelbl.text=[NSString stringWithFormat:@"%@:%@",@"Time",datestr];
    //Timelbl.text=[[NSDate date] description];
    
    
}
-(void)settaxSelectionMethod
{
    NSArray *array=[Tax componentsSeparatedByString:@","];
    NSString *tax1value,*tax2value,*tax3value,*bartaxvalue;
    for (int i=0; i<[array count]; i++)
    {
        
        NSString  *tvalue=[array objectAtIndex:i];
        if ([tvalue isEqualToString:tax1Name])
        {
            tax1value=tvalue;
        }
        if ([tvalue isEqualToString:tax2Name])
        {
            tax2value=tvalue;
        }
        if ([tvalue isEqualToString:tax3Name])
        {
            tax3value=tvalue;
        }
        if ([tvalue isEqualToString:@"Bartax"])
        {
            bartaxvalue=tvalue;
        }
        
    }
    
    if ([tax1value isEqualToString:tax1Name])
    {
        tax1Btn.selected=YES;
        
    }
    else
    {
        tax1Btn.selected=NO;
    }
    if ([tax2value isEqualToString:tax2Name])
    {
        tax2Btn.selected=YES;
        
    }
    else
    {
        tax2Btn.selected=NO;
    }
    if ([tax3value isEqualToString:tax3Name])
    {
        tax3Btn.selected=YES;
        
    }
    else
    {
        tax3Btn.selected=NO;
    }
    
    if ([bartaxvalue isEqualToString:@"Bartax"])
    {
       BarTaxBtn.selected=YES;
        
    }
    else
    {
        BarTaxBtn.selected=NO;
    }
    
    [self Totaltaxmethod];
    array=nil,tax1value=tax2value=tax3value=bartaxvalue=nil;
}
-(void)CategorySelectedBtn
{
    NSString *querySQL6 = [NSString stringWithFormat: @"SELECT category_id FROM category_details"];
    NSMutableArray *catsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL6 resultsArray:catsArray];
    
    categorynamesArray=[[NSMutableArray alloc]init];
    [categorynamesArray addObject:@"All"];
    @autoreleasepool {
        for (NSDictionary *myDict in catsArray)
        {        NSString *catname=[myDict objectForKey:@"category_id"];
            [categorynamesArray addObject:catname];
            
        }
    }
    
    Pcategorypopup=[[UIView alloc]init];
    if (isLandScope) {
        Pcategorypopup.frame=CGRectMake(0, 0, 1024, 768);
    }else{
        
        Pcategorypopup.frame=CGRectMake(0, 0, 768, 1024);
    }
    [Pcategorypopup setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:Pcategorypopup];
    
    PCategorysTable=[[UITableView alloc]init];
    //[editProductTable  setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    [PCategorysTable setBackgroundColor:[UIColor whiteColor]];
    PCategorysTable.frame=CGRectMake(100,200 ,Pcategorypopup.frame.size.width-200, Pcategorypopup.frame.size.height-400);
    
    //editProductTable.contentSize = CGSizeMake(ProductView.frame.size.width+1000, ProductView.frame.size.height+1000);
    PCategorysTable.delegate=self;
    PCategorysTable.dataSource=self;
    
    [Pcategorypopup addSubview:PCategorysTable];

    
}
-(void)DepartmentSelectedBtn
{
    
    NSString *querySQL7 = [NSString stringWithFormat: @"SELECT department_id FROM department_details"];
    NSMutableArray *deptsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:deptsArray];
    
    DepartmentNamesArray=[[NSMutableArray alloc]init];
     [DepartmentNamesArray addObject:@"All"];
    @autoreleasepool {
        for (NSDictionary *myDict in deptsArray)
        {
            
            NSString *catname=[myDict objectForKey:@"department_id"];
            [DepartmentNamesArray addObject:catname];
            
        }
    }
   
    Pdeaprtmentpopup=[[UIView alloc]init];
    if (isLandScope) {
        Pdeaprtmentpopup.frame=CGRectMake(0, 0, 1024, 768);
    }
    
    else{
        
        Pdeaprtmentpopup.frame=CGRectMake(0, 0, 768, 1024);
    }
    [Pdeaprtmentpopup setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:Pdeaprtmentpopup];
    
    PdepartmentsTable=[[UITableView alloc]init];
    //[editProductTable  setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    [PdepartmentsTable setBackgroundColor:[UIColor whiteColor]];
    PdepartmentsTable.frame=CGRectMake(100,200 ,Pdeaprtmentpopup.frame.size.width-200, Pdeaprtmentpopup.frame.size.height-400);
    
    //editProductTable.contentSize = CGSizeMake(ProductView.frame.size.width+1000, ProductView.frame.size.height+1000);
    PdepartmentsTable.delegate=self;
    PdepartmentsTable.dataSource=self;
    
    [Pdeaprtmentpopup addSubview:PdepartmentsTable];
    
    
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    
    if(textField == SearchField)
    {
        SearchlistTable.hidden = NO;
        NSString *substring = [NSString stringWithString:textField.text];
        substring = [substring stringByReplacingCharactersInRange:range withString:string];
        [self searchAutocompleteEntriesWithSubstring:substring];
    }
    return YES;
    
}
- (void)searchAutocompleteEntriesWithSubstring:(NSString *)substring {
    
    // Put anything that starts with this substring into the autocompleteUrls array
    // The items in this array is what will show up in the table view
    if ([substring length]>=2)
    {
        [SearchDataArray removeAllObjects];
        for(NSMutableString *curString in pastDataArray)
        {
            NSRange titleResultsRange = [curString rangeOfString:substring options:NSCaseInsensitiveSearch];
            
            if (titleResultsRange.length > 0)
                [SearchDataArray addObject:curString];
            
        }
        [SearchlistTable reloadData];
        
    }
    else
    {
        SearchlistTable.hidden=YES;
    }
}

-(void)GoBtnClicked
{
    NSString *selectsql;
    NSString *CatID=[NSString stringWithFormat:@"%@",CatField.titleLabel.text];
    NSString *DeptID=[NSString stringWithFormat:@"%@",DeptField.titleLabel.text];
    
    
   

     if ([CatID isEqualToString:@"All"]&&!([SearchField.text length]==0))
    {
        selectsql=[NSString stringWithFormat:@"SELECT  inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id FROM inventorytable WHERE inventory_item_no like'%%%@%%'OR inventary_item_name like '%%%@%%' limit 100 offset 0 ",SearchField.text,SearchField.text];
        // //NSLog(@" seletced query %@",selectsql);
       
    }
      if(!([SearchField.text length]==0)&&[DeptID isEqualToString:@"All"])
     {
         selectsql=[NSString stringWithFormat:@"SELECT  inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id FROM inventorytable WHERE inventory_item_no like'%%%@%%'OR inventary_item_name like '%%%@%%' limit 100 offset 0 ",SearchField.text,SearchField.text];
         // //NSLog(@" seletced query %@",selectsql);
     }
    if(!([SearchField.text length]==0) && ![DeptID isEqualToString:@"All"])
    {
        selectsql=[NSString stringWithFormat:@"SELECT  inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id FROM inventorytable WHERE inventory_item_no like'%%%@%%'OR inventary_item_name like '%%%@%%'OR inventary_department='%@' limit 100 offset 0 ",SearchField.text,SearchField.text,DeptID];
        // //NSLog(@" seletced query %@",selectsql);
    }
    if(!([SearchField.text length]==0) && ![CatID isEqualToString:@"All"])
    {
        selectsql=[NSString stringWithFormat:@"SELECT  inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id FROM inventorytable WHERE inventory_item_no like'%%%@%%'OR inventary_item_name like '%%%@%%'OR category_id='%@' limit 100 offset 0",SearchField.text,SearchField.text,CatID];
        // //NSLog(@" seletced query %@",selectsql);
    }
 
     if (![CatID isEqualToString:@"All"]&&![DeptID isEqualToString:@"All"])
    {
        selectsql=[NSString stringWithFormat:@"SELECT  inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id FROM inventorytable WHERE inventary_department='%@' OR category_id='%@' limit 100 offset 0",DeptID,CatID];
        // //NSLog(@" seletced query %@",selectsql);
    }
     if (![CatID isEqualToString:@"All"]&&[DeptID isEqualToString:@"All"])
    {
        selectsql=[NSString stringWithFormat:@"SELECT  inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id FROM inventorytable WHERE category_id='%@' limit 100 offset 0",[CatID stringByReplacingOccurrencesOfString:@" " withString:@""]];
        // //NSLog(@" seletced query %@",selectsql);
        
    }
     if(![DeptID isEqualToString:@"All"]&&[CatID isEqualToString:@"All"])
    {
        selectsql=[NSString stringWithFormat:@"SELECT  inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id FROM inventorytable WHERE inventary_department='%@' limit 100 offset 0 ",DeptID];
        // //NSLog(@" seletced query %@",selectsql);
        
    }
    if (![CatID isEqualToString:@"All"]&&![DeptID isEqualToString:@"All"]&& !([SearchField.text length]==0))
    {
        selectsql=[NSString stringWithFormat:@"SELECT  inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id FROM inventorytable WHERE inventory_item_no like'%%%@%%'OR inventary_item_name like '%%%@%%' OR inventary_department='%@' OR category_id='%@' limit 100 offset 0 ",SearchField.text,SearchField.text,DeptID,CatID];
        
    }
    if ([selectsql length]>0)
    {
        
    }
    NSMutableArray *productDataArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:selectsql resultsArray:productDataArray];
  
    if ([productDataArray count]>0)
    {
        [productPaginationObject  ResultsPerset:[productDataArray count]];
        
        [productPaginationObject  ResultspersetArray];
        
        [DisplaySettable reloadData];
        [ResultspersetBtn setTitle:[[productPaginationObject  ResultspersetArray] objectAtIndex:0] forState:UIControlStateNormal];
        SelectedResultsForSet=[[productPaginationObject  ResultspersetArray] objectAtIndex:0];
      
    
        
        NSMutableArray *rdarray=productDataArray;
    
        //NSMutableArray *updateTableArray3=[[NSMutableArray alloc] init];
        
        [productPaginationObject  setCompleteresultset:rdarray];
        
        [productPaginationObject   paginationinitializer:rdarray :10];
        
        [productPaginationObject  paginationsegment].tintColor=[UIColor whiteColor];
        [[productPaginationObject  paginationsegment] setFrame:CGRectMake(0,140 ,EditProductBackView.frame.size.width, 40)];
        
        [[productPaginationObject  paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
        
        NSInteger selectedsegindex;
        selectedsegindex=0;
        [productPaginationObject  paginationsegment].selectedSegmentIndex=selectedsegindex;
       [productPaginationObject  activateResults:selectedsegindex];
        [EditProductBackView addSubview:[productPaginationObject  paginationsegment]];
        
        [editProductTable reloadData];
    }
    else
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Alert" message:@"No results Available" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:Nil, nil];
        [alert show];
        [productPaginationObject  ResultsPerset:[productDataArray count]];
        
        [productPaginationObject  ResultspersetArray];
        
        [DisplaySettable reloadData];
        [ResultspersetBtn setTitle:@"" forState:UIControlStateNormal];
        
        [self ProductpaginationMetod];

        
    }

    
   
}
-(void)ProductpaginationMetod
{
   // NSString  *strp;
    
   /* ProductDepartmentsArray=Nil;
    ItemNumbersArray=Nil;
    ItemnameArray=nil;
    productDesArray=nil;
    CostArray=nil;
    priceyouchargeArray=nil;
    pricewithTaxArray=nil;
    InstockArray=nil;
    productVendorsArray=nil;
    taxvaluesArray=nil;
    productNotesArray=nil;
    
    VendorpartNosArray=nil;*/
    if ([[productPaginationObject  ResultspersetArray]count]>0)
    {

        NSArray *array=[SelectedResultsForSet componentsSeparatedByString:@"-"];

        SelectedResultsForSet=[array objectAtIndex:0];
     
        int str=[SelectedResultsForSet intValue];
        NSString *selectsql=[NSString stringWithFormat:@"SELECT inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id FROM inventorytable limit 50 offset %d",str-1];
        // // //NSLog(@" seletced query %@",selectsql);
        NSMutableArray *productsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:selectsql resultsArray:productsArray];
        NSMutableArray *rdarray=productsArray;
    
        [productPaginationObject  setCompleteresultset:rdarray];
        
        [productPaginationObject   paginationinitializer:rdarray :10];
        
        [productPaginationObject  paginationsegment].tintColor=[UIColor whiteColor];
        [[productPaginationObject  paginationsegment] setFrame:CGRectMake(0,140 ,EditProductBackView.frame.size.width, 40)];
        
        [[productPaginationObject  paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
        
        NSInteger selectedsegindex;
        selectedsegindex=0;
        [productPaginationObject  paginationsegment].selectedSegmentIndex=selectedsegindex;
        
       [productPaginationObject  activateResults:selectedsegindex];
        
        
        [EditProductBackView addSubview:[productPaginationObject  paginationsegment]];
        [self productRelatedDataMethod];
        [editProductTable reloadData];
        
        
    }
    else
    {
        SelectedResultsForSet=@"";
        NSString *selectsql=[NSString stringWithFormat:@"SELECT inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id FROM inventorytable limit '%@' offset '%@'",@"0",@"0"];
        // // //NSLog(@" seletced query %@",selectsql);
        NSMutableArray *productsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:selectsql resultsArray:productsArray];
        NSMutableArray *rdarray=productsArray;
      //  NSMutableArray *updateTableArray3=[[NSMutableArray alloc] init];
        
        [productPaginationObject  setCompleteresultset:rdarray];
        
        [productPaginationObject   paginationinitializer:rdarray :10];
        
        [productPaginationObject  paginationsegment].tintColor=[UIColor whiteColor];
        //[[productPaginationObject  paginationsegment] setFrame:CGRectMake(0,140 ,EditProductBackView.frame.size.width, 40)];
        
        [[productPaginationObject  paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
        
        NSInteger selectedsegindex;
        selectedsegindex=0;
        [productPaginationObject  paginationsegment].selectedSegmentIndex=selectedsegindex;
      [productPaginationObject  activateResults:selectedsegindex];
        [EditProductBackView addSubview:[productPaginationObject  paginationsegment]];
          [self productRelatedDataMethod];
        [editProductTable reloadData];
    }
    
  
  
}
#pragma mark -
#pragma mark - Toolbar items change method
-(void)productbtnclicked
{
    [self removeallCategoryArraysMethod];
    [self removeallDeptsArraysMethod];
    [self removeallvendorArraysMethod];
    
   

  
    VendornumbersArray=[[NSMutableArray alloc]init];
  NSString *querySQL = [NSString stringWithFormat: @"SELECT vendor_no FROM vendor"];
    NSMutableArray *venodrsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:venodrsArray];
    @autoreleasepool {
        for (NSDictionary *myDict in venodrsArray)
        {
            NSString *vendorno=[myDict objectForKey:@"vendor_no"];
            
            [VendornumbersArray addObject:vendorno];
        }
    }
   
 
    CategoryBtn.selected=NO;
    DepartmentsBtn.selected=NO;
    VendorsBtn.selected=NO;
    ProductBtn.selected=YES;
   
    // removing all the subviews associated with AddvendorsView such that they can be
    // allocated many times without adding for n times on the same view.
    
    NSArray *AddvendorsViewArray = AddvendorsView.subviews;
    for (int i = 0; i<[AddvendorsViewArray count]; i++) {
        UIView *vi =[AddvendorsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *vendorsViewArray = vendorsView.subviews;
    for (int i = 0; i<[vendorsViewArray count]; i++) {
        UIView *vi =[vendorsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [AddvendorsView removeFromSuperview],[vendorsView removeFromSuperview];
    
  
    NSArray *addCategoryViewArray = addCategoryView.subviews;
    for (int i = 0; i<[addCategoryViewArray count]; i++) {
        UIView *vi =[addCategoryViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addCategoryBackViewArray = addCategoryBackView.subviews;
    for (int i = 0; i<[addCategoryBackViewArray count]; i++) {
        UIView *vi =[addCategoryBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addCategoryView removeFromSuperview],[addCategoryBackView removeFromSuperview];
    
    NSArray *addDepartmentViewArray = addDepartmentView.subviews;
    for (int i = 0; i<[addDepartmentViewArray count]; i++) {
        UIView *vi =[addDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *depertmentViewArray = depertmentView.subviews;
    for (int i = 0; i<[depertmentViewArray count]; i++) {
        UIView *vi =[depertmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addDepartmentView removeFromSuperview],[depertmentView removeFromSuperview];
   
   if(!ProductView)
    ProductView=[[UIView alloc]init];
    ProductView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
    [ProductView setBackgroundColor:[UIColor whiteColor]];
    ProductView.layer.cornerRadius=8;
    [mainview addSubview:ProductView];
    @autoreleasepool {
        AddProductBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        [AddProductBtn setTitle:@"Add Product" forState:UIControlStateNormal];
        
        CGFloat addbuttonwidth4=(ProductView.frame.size.width-5)/2;
        AddProductBtn.frame=CGRectMake(5, 10, addbuttonwidth4, 40);
        //[AddProductBtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
        [AddProductBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bluetabactive" ofType:@"png"]] forState:UIControlStateSelected];
        [AddProductBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [AddProductBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
        AddProductBtn.selected=YES;
        //addtaxBtn.layer.cornerRadius=8;
        [AddProductBtn addTarget:self action:@selector(AddProductClicked) forControlEvents:UIControlEventTouchUpInside];
        [ProductView addSubview:AddProductBtn];
        
        EditProductBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        [EditProductBtn setTitle:@"View & Edit Product" forState:UIControlStateNormal];
        EditProductBtn.frame=CGRectMake(AddProductBtn.frame.size.width, 10, addbuttonwidth4, 40);
        //EditCategoryBtn.backgroundColor=[UIColor colorWithRed:203.0f green:203.0f/255.0f blue:203.0f/255.0f alpha:1.0f];
        [EditProductBtn setBackgroundColor:[UIColor whiteColor]];
        [EditProductBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [EditProductBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bluetabactive" ofType:@"png"]] forState:UIControlStateSelected];
        [EditProductBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [EditProductBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
        EditProductBtn.selected=NO;
        [EditProductBtn addTarget:self action:@selector(EditProductClicked) forControlEvents:UIControlEventTouchUpInside];
        [ProductView addSubview:EditProductBtn];
    }
   
    //add product view
    if(!AddProductScrollView)
    AddProductScrollView=[[UIScrollView alloc]init];
    AddProductScrollView.frame=CGRectMake(5, AddProductBtn.frame.size.height+10, ProductView.frame.size.width-10, ProductView.frame.size.height-20-AddProductBtn.frame.size.height);
    [AddProductScrollView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    AddProductScrollView.contentSize=CGSizeMake(ProductView.frame.size.width-10, ProductView.frame.size.height-20-AddProductBtn.frame.size.height+500);
    
    [ProductView addSubview:AddProductScrollView];
    CGFloat Productfieldwidth=(AddProductScrollView.frame.size.width-100)/4;
    CGFloat r=(Productfieldwidth/2)+20;
      if(!Departmentlbl)
    Departmentlbl=[[UILabel alloc] init];
    Departmentlbl.frame=CGRectMake(r-80, 30,Productfieldwidth, 50);
    [Departmentlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Departmentlbl setBackgroundColor:[UIColor clearColor]];
    [Departmentlbl setTextColor:[UIColor whiteColor]];
    [Departmentlbl setText:@"Department for this Item"];
    Departmentlbl.lineBreakMode = NSLineBreakByWordWrapping;
    Departmentlbl.numberOfLines = 2;
    [Departmentlbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:Departmentlbl];
    
     NSString *querySQL7 = [NSString stringWithFormat:@"SELECT department_id,department_totaltax,department_foodstampable FROM department_details"];
    NSMutableArray *deptsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:deptsArray];
     NSString *Dept;
    
    DepartmentNamesArray=[[NSMutableArray alloc]init];
    depttaxesArray=[[NSMutableArray alloc]init];
    deptfoodsArray=[[NSMutableArray alloc]init];
    if ([deptsArray count]>0)
    {
        for (NSDictionary *myDict in deptsArray)
        {
            
            NSString *catname=[myDict objectForKey:@"department_id"];
            [DepartmentNamesArray addObject:catname];
            NSString *tax=[myDict objectForKey:@"department_totaltax"];
            [depttaxesArray addObject:tax];
            [deptfoodsArray addObject:[myDict objectForKey:@"department_foodstampable"]];
            catname=nil,tax=nil;
        }
        Dept=[DepartmentNamesArray objectAtIndex:0];
        
        Tax=[depttaxesArray objectAtIndex:0];
        foodstampable=[deptfoodsArray objectAtIndex:0];
    }
    
    
    DepartmentBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    DepartmentBtn.frame=CGRectMake(Productfieldwidth+5, 30, Productfieldwidth-10, 40);
    [DepartmentBtn addTarget:self action:@selector(DepartmentBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [DepartmentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DepartmentBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [DepartmentBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [DepartmentBtn setTitle:Dept  forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [AddProductScrollView addSubview:DepartmentBtn];
    if(!DepartmentsTable)
    DepartmentsTable = [[UITableView alloc] initWithFrame:CGRectMake(Productfieldwidth+5, 70, Productfieldwidth-10, 100) style:UITableViewStylePlain];
    DepartmentsTable.backgroundColor=[UIColor whiteColor];
    DepartmentsTable.delegate = self;
    DepartmentsTable.dataSource = self;
    DepartmentsTable.scrollEnabled = YES;
    DepartmentsTable.hidden=YES;
    [DepartmentsTable.layer setBorderWidth: 1.0];
    [DepartmentsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [AddProductScrollView addSubview:DepartmentsTable];
    [DepartmentsTable reloadData];
      if(!ItemNumberlbl)
    ItemNumberlbl=[[UILabel alloc] init];
    ItemNumberlbl.frame=CGRectMake(r-80, 90,Productfieldwidth, 40);
    [ItemNumberlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [ItemNumberlbl setBackgroundColor:[UIColor clearColor]];
    [ItemNumberlbl setTextColor:[UIColor whiteColor]];
    [ItemNumberlbl setText:@"Item Number"];
    [ItemNumberlbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:ItemNumberlbl];
     if(!ItemNumberField)
    ItemNumberField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    ItemNumberField.frame=CGRectMake(Productfieldwidth+5, 90,Productfieldwidth-10, 40);
    ItemNumberField.delegate=self;
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    ItemNumberField.leftView = paddingview;
    ItemNumberField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    ItemNumberField.leftViewMode = UITextFieldViewModeAlways;
    [ItemNumberField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    
    //[DepartmentBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [ItemNumberField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddProductScrollView addSubview:ItemNumberField];
     if(!ItemNamelbl)
    ItemNamelbl=[[UILabel alloc] init];
    ItemNamelbl.frame=CGRectMake(r-80, 150,Productfieldwidth, 40);
    [ItemNamelbl setFont:[UIFont systemFontOfSize:20.0f]];
    [ItemNamelbl setBackgroundColor:[UIColor clearColor]];
    [ItemNamelbl setTextColor:[UIColor whiteColor]];
    [ItemNamelbl setText:@"Item Name"];
    [ItemNamelbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:ItemNamelbl];
     if(!ItemNameField)
    ItemNameField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    ItemNameField.frame=CGRectMake(Productfieldwidth+5, 150,Productfieldwidth-10, 40);
    ItemNameField.delegate=self;
    UIView *paddingview2=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    ItemNameField.leftView = paddingview2;
    ItemNameField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    ItemNameField.leftViewMode = UITextFieldViewModeAlways;
    //[ItemNameField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [ItemNameField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [ItemNameField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddProductScrollView addSubview:ItemNameField];
     if(!Descroptionlbl)
    Descroptionlbl=[[UILabel alloc] init];
    Descroptionlbl.frame=CGRectMake(r-80, 210,Productfieldwidth+10, 40);
    [Descroptionlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Descroptionlbl setBackgroundColor:[UIColor clearColor]];
    [Descroptionlbl setTextColor:[UIColor whiteColor]];
    [Descroptionlbl setText:@"2nd Description"];
    [Descroptionlbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:Descroptionlbl];
     if(!DescriptionText)
    DescriptionText=[[UITextView alloc] init];
    DescriptionText.frame=CGRectMake(Productfieldwidth+5, 200,Productfieldwidth-10,80);
    DescriptionText.delegate=self;
    DescriptionText.font=[UIFont systemFontOfSize:14.0f];
    [DescriptionText setAutocorrectionType:UITextAutocorrectionTypeNo];
    DescriptionText.layer.cornerRadius=8;
    [AddProductScrollView addSubview:DescriptionText];
       if(!Costlbl)
    Costlbl=[[UILabel alloc] init];
    Costlbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15, 30,Productfieldwidth+10, 40);
    [Costlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Costlbl setBackgroundColor:[UIColor clearColor]];
    [Costlbl setTextColor:[UIColor whiteColor]];
    
    [Costlbl setText:@"Cost"];
    [Costlbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:Costlbl];
     if(!CostField)
    CostField=[[UITextField alloc] init];
    CostField.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5, 30,Productfieldwidth-10, 40);
    [CostField addTarget:self action:@selector(AddressFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
    CostField.delegate=self;
    UIView *paddingview3=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    CostField.leftView = paddingview3;
    CostField.keyboardType=UIKeyboardTypeNumberPad;
    CostField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    CostField.leftViewMode = UITextFieldViewModeAlways;
    //[CostField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [CostField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [CostField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddProductScrollView addSubview:CostField];
     if(!priceyouChargelbl)
    priceyouChargelbl=[[UILabel alloc] init];
    priceyouChargelbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15,90,Productfieldwidth+10, 40);
    [priceyouChargelbl setFont:[UIFont systemFontOfSize:20.0f]];
    [priceyouChargelbl setBackgroundColor:[UIColor clearColor]];
    [priceyouChargelbl setTextColor:[UIColor whiteColor]];
     if(!priceyouChargelbl)
    [priceyouChargelbl setText:@"Price You Charge"];
    [priceyouChargelbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:priceyouChargelbl];
    if(!PriceyouChargeField)
    PriceyouChargeField=[[UITextField alloc] init];
    PriceyouChargeField.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,90,Productfieldwidth-10, 40);
    [PriceyouChargeField addTarget:self action:@selector(PriceYouChargeClicked:) forControlEvents:UIControlEventEditingDidEnd];
    PriceyouChargeField.delegate=self;
    UIView *paddingview4=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    PriceyouChargeField.leftView = paddingview4;
    PriceyouChargeField.keyboardType=UIKeyboardTypeNumberPad;
    PriceyouChargeField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    PriceyouChargeField.leftViewMode = UITextFieldViewModeAlways;
    //[PriceyouChargeField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [PriceyouChargeField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [PriceyouChargeField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddProductScrollView addSubview:PriceyouChargeField];
    if(!priceWithTaxlbl)
    priceWithTaxlbl=[[UILabel alloc] init];
    priceWithTaxlbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15,150,Productfieldwidth+10, 40);
    [priceWithTaxlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [priceWithTaxlbl setBackgroundColor:[UIColor clearColor]];
    [priceWithTaxlbl setTextColor:[UIColor whiteColor]];
    [priceWithTaxlbl setText:@"Price with Tax"];
    [priceWithTaxlbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:priceWithTaxlbl];
     if(!PriceWithTaxBtn)
    PriceWithTaxBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    PriceWithTaxBtn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,150,Productfieldwidth-10, 40);
    [PriceWithTaxBtn addTarget:self action:@selector(pricewithTaxClicked) forControlEvents:UIControlEventTouchUpInside];
    
    [PriceWithTaxBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [PriceWithTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]] forState:UIControlStateNormal];
    [AddProductScrollView addSubview:PriceWithTaxBtn];
      if(!InStocklbl)
    InStocklbl=[[UILabel alloc] init];
    InStocklbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15,210,Productfieldwidth+10, 40);
    [InStocklbl setFont:[UIFont systemFontOfSize:20.0f]];
    [InStocklbl setBackgroundColor:[UIColor clearColor]];
    [InStocklbl setTextColor:[UIColor whiteColor]];
    
    [InStocklbl setText:@"In Stock"];
    [InStocklbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:InStocklbl];
     if(!InStockField)
    InStockField=[[UITextField alloc] init];
    InStockField.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,210,Productfieldwidth-10, 40);
    [InStockField addTarget:self action:@selector(AddressFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
    InStockField.delegate=self;
    UIView *paddingview5=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    InStockField.leftView = paddingview5;
    InStockField.keyboardType=UIKeyboardTypeNumberPad;
    InStockField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    InStockField.leftViewMode = UITextFieldViewModeAlways;
    // [InStockField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [InStockField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [InStockField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddProductScrollView addSubview:InStockField];
     if(!Addpricinglbl)
    Addpricinglbl=[[UILabel alloc] init];
    Addpricinglbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15,270,Productfieldwidth+10, 50);
    [Addpricinglbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Addpricinglbl setBackgroundColor:[UIColor clearColor]];
    [Addpricinglbl setTextColor:[UIColor whiteColor]];
    
    [Addpricinglbl setText:@"Addpricing from a Vendor"];
    Addpricinglbl.lineBreakMode = NSLineBreakByWordWrapping;
    Addpricinglbl.numberOfLines = 2;
    [Addpricinglbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:Addpricinglbl];
    
    if(!AddpricingBtn)
    AddpricingBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    AddpricingBtn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,270,Productfieldwidth-10, 40);
    [AddpricingBtn addTarget:self action:@selector(AddpricingClicked) forControlEvents:UIControlEventTouchUpInside];
    // [AddpricingBtn setTitle:[VendornumbersArray objectAtIndex:0] forState:UIControlStateNormal];
    [AddpricingBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[AddpricingBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [AddpricingBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    
    [AddProductScrollView addSubview:AddpricingBtn];
    
     if(!VendorsTable)
    VendorsTable = [[UITableView alloc] initWithFrame:CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,170,Productfieldwidth-10, 100) style:UITableViewStylePlain];
    VendorsTable.backgroundColor=[UIColor whiteColor];
    VendorsTable.delegate = self;
    VendorsTable.dataSource = self;
    VendorsTable.scrollEnabled = YES;
    VendorsTable.hidden=YES;
    [VendorsTable.layer setBorderWidth: 1.0];
    [VendorsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [AddProductScrollView addSubview:VendorsTable];
    [VendorsTable reloadData];
     if(!tax1Btn)
    tax1Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    tax1Btn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+10,35,30, 30);
    [tax1Btn addTarget:self action:@selector(Tax1Clicked) forControlEvents:UIControlEventTouchUpInside];
    [tax1Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[tax1Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [tax1Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    //[tax1Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [tax1Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [AddProductScrollView addSubview:tax1Btn];
     if(!tax1lbl)
    tax1lbl=[[UILabel alloc] init];
    tax1lbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+45,30,50, 40);
    [tax1lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [tax1lbl setBackgroundColor:[UIColor clearColor]];
    [tax1lbl setTextColor:[UIColor whiteColor]];
    tax1Btn.selected=YES;
    [tax1lbl setText:tax1Name];
    
    [tax1lbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:tax1lbl];
    
     if(!tax2Btn)
    tax2Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    tax2Btn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+10,95,30, 30);
    [tax2Btn addTarget:self action:@selector(Tax2Clikced) forControlEvents:UIControlEventTouchUpInside];
    [tax2Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[tax2Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [tax2Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    //[tax2Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [tax2Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    
    [AddProductScrollView addSubview:tax2Btn];
      if(!tax2lbl)
    tax2lbl=[[UILabel alloc] init];
    tax2lbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+45,90,50, 40);
    [tax2lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [tax2lbl setBackgroundColor:[UIColor clearColor]];
    [tax2lbl setTextColor:[UIColor whiteColor]];
    
    [tax2lbl setText:tax2Name];
    
    [tax2lbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:tax2lbl];
     if(!tax3Btn)
    tax3Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    tax3Btn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+10,155,30, 30);
    [tax3Btn addTarget:self action:@selector(Tax3Clicked) forControlEvents:UIControlEventTouchUpInside];
    [tax3Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[tax3Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [tax3Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    //[tax3Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [tax3Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [AddProductScrollView addSubview:tax3Btn];
     if(!tax3lbl)
    tax3lbl=[[UILabel alloc] init];
    tax3lbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+45,150,50, 40);
    [tax3lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [tax3lbl setBackgroundColor:[UIColor clearColor]];
    [tax3lbl setTextColor:[UIColor whiteColor]];
    
    [tax3lbl setText:tax3Name];
    
    [tax3lbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:tax3lbl];
     if(!BarTaxBtn)
    BarTaxBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    BarTaxBtn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+10,215,30, 30);
    [BarTaxBtn addTarget:self action:@selector(BarBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [BarTaxBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[BarTaxBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[BarTaxBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    
    [BarTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    //[tax3Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [BarTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    [AddProductScrollView addSubview:BarTaxBtn];
    [self settaxSelectionMethod];
     if(!bartaxlbl)
    bartaxlbl=[[UILabel alloc] init];
    bartaxlbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+45,210,80, 40);
    [bartaxlbl setFont:[UIFont systemFontOfSize:18.0f]];
    [bartaxlbl setBackgroundColor:[UIColor clearColor]];
    [bartaxlbl setTextColor:[UIColor whiteColor]];
    [bartaxlbl setText:@"Bartax"];
    [bartaxlbl setTextAlignment:NSTextAlignmentLeft];
    [AddProductScrollView addSubview:bartaxlbl];
    CGFloat wdth=(AddProductScrollView.frame.size.width)/4;
          NSArray *array2=[[NSArray alloc]initWithObjects:@"Optional Info",@"Notes",@"Modifiers",nil];
        NSArray *array3=[[NSArray alloc]initWithObjects:@"Ordering Info",@"SalesHistory", @"printers",nil];
    CGFloat xvalue=wdth/4;
    @autoreleasepool {
        for (int k=0; k<3; k++)
        {
            infoButtons = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            [infoButtons setTitle:[array2 objectAtIndex:k] forState:UIControlStateNormal];
            //[infoButtons setBackgroundImage:[UIImage imageNamed:@"additionaloptions.png"] forState:UIControlStateNormal];
            [infoButtons setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"additionaloptions" ofType:@"png"]] forState:UIControlStateNormal];
            infoButtons.frame=CGRectMake(xvalue+20,350,wdth+5, 40);
            
            [infoButtons addTarget:self action:@selector(infoButton1Clicked:) forControlEvents:UIControlEventTouchUpInside];
            infoButtons.tag=k+100;
            [infoButtons setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            
            [AddProductScrollView addSubview:infoButtons];
            xvalue=xvalue+wdth+15;
            
        }
        
        CGFloat wdth2=(AddProductScrollView.frame.size.width)/4;
        CGFloat valuex=wdth2/4;
        for (int j=0; j<3; j++)
        {
            infoButton2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            [infoButton2 setTitle:[array3 objectAtIndex:j] forState:UIControlStateNormal];
            //[infoButton2 setBackgroundImage:[UIImage imageNamed:@"additionaloptions.png"] forState:UIControlStateNormal];
            [infoButton2 setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"additionaloptions" ofType:@"png"]] forState:UIControlStateNormal];
            
            infoButton2.frame=CGRectMake(valuex+20,400,wdth2+5, 40);
            [infoButton2 addTarget:self action:@selector(infoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
            
            [infoButton2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            infoButton2.tag=j+100;
            if (infoButton2.tag==102)
            {
                infoButton2.hidden=YES;
            }
            [AddProductScrollView addSubview:infoButton2];
            
            valuex=valuex+wdth2+15;
            
        }
        
        
        SaveProductBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        SaveProductBtn.frame=CGRectMake(Productfieldwidth+140, 500, 80, 30);
        [SaveProductBtn addTarget:self action:@selector(SaveProductData) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [SaveProductBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[SaveProductBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [SaveProductBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        
        [AddProductScrollView addSubview:SaveProductBtn];
        
        CancelProductBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        CancelProductBtn.frame=CGRectMake(Productfieldwidth+240, 500, 80, 30);
        [CancelProductBtn addTarget:self action:@selector(CancelProductData) forControlEvents:UIControlEventTouchUpInside];
        [CancelProductBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[CancelProductBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        [CancelProductBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [AddProductScrollView addSubview:CancelProductBtn];
    }
  

    //edit product view
    if (!EditProductBackView)
    EditProductBackView=[[UIView alloc]init];
    EditProductBackView.frame=CGRectMake(5, AddProductBtn.frame.size.height+10, ProductView.frame.size.width-10, ProductView.frame.size.height-20-AddProductBtn.frame.size.height);
    
    [EditProductBackView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    
    
    CGFloat SearchW=(ProductView.frame.size.width-10)/2;
    CGFloat SW=SearchW/2;
     if (!Catlbl)
    Catlbl=[[UILabel alloc] init];
    Catlbl.frame=CGRectMake(5,5,SW-20,40);
    [Catlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Catlbl setBackgroundColor:[UIColor clearColor]];
    [Catlbl setTextColor:[UIColor whiteColor]];
    [Catlbl setText:@"Category"];
    [Catlbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductBackView addSubview:Catlbl];
    
     if (!CatField)
    CatField = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    CatField.frame=CGRectMake(Catlbl.frame.size.width,5,SW+15,35);
    [CatField addTarget:self action:@selector(CategorySelectedBtn) forControlEvents:UIControlEventTouchUpInside];
    [CatField setTitle:@"All"  forState:UIControlStateNormal];
    
    [CatField setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [CatField setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [EditProductBackView addSubview:CatField];
    if (!Deptlbl)
    Deptlbl=[[UILabel alloc] init];
    Deptlbl.frame=CGRectMake(5,45,SW-20, 40);
    [Deptlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Deptlbl setBackgroundColor:[UIColor clearColor]];
    [Deptlbl setTextColor:[UIColor whiteColor]];
    [Deptlbl setText:@"Department"];
    [Deptlbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductBackView addSubview:Deptlbl];
    
    if (!DeptField)
    DeptField = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    DeptField.frame=CGRectMake(Deptlbl.frame.size.width,45,SW+15, 40);
    [DeptField addTarget:self action:@selector(DepartmentSelectedBtn) forControlEvents:UIControlEventTouchUpInside];
    
    [DeptField setTitle:@"All" forState:UIControlStateNormal];
    
    [DeptField setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DeptField setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [DeptField setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [EditProductBackView addSubview:DeptField];
     if (!Searchlbl)
    Searchlbl=[[UILabel alloc] init];
    Searchlbl.frame=CGRectMake(5,90,SW-20, 40);
    [Searchlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Searchlbl setBackgroundColor:[UIColor clearColor]];
    [Searchlbl setTextColor:[UIColor whiteColor]];
    [Searchlbl setText:@"Search"];
    [Searchlbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductBackView addSubview:Searchlbl];
       if (!SearchField)
    SearchField=[[UITextField alloc] init];
    SearchField.frame=CGRectMake(Deptlbl.frame.size.width,90,SW+15, 40);
    [SearchField addTarget:self action:@selector(AddressFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
    SearchField.delegate=self;
    UIView *paddingview10=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    SearchField.leftView = paddingview10;
    SearchField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    SearchField.leftViewMode = UITextFieldViewModeAlways;
    //[SearchField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [SearchField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    
    [SearchField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditProductBackView addSubview:SearchField];
     if (!SearchlistTable)
    SearchlistTable = [[UITableView alloc] initWithFrame:CGRectMake(Deptlbl.frame.size.width,5,SW+15, 90) style:UITableViewStylePlain];
    SearchlistTable.backgroundColor=[UIColor whiteColor];
    SearchlistTable.delegate = self;
    SearchlistTable.dataSource = self;
    SearchlistTable.scrollEnabled = YES;
    SearchlistTable.hidden=YES;
    [SearchlistTable.layer setBorderWidth: 1.0];
    [SearchlistTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditProductBackView addSubview:SearchlistTable];
    if (!Gobtn)
    Gobtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    Gobtn.frame=CGRectMake(Deptlbl.frame.size.width+SearchField.frame.size.width+5,45,40, 40);
    [Gobtn addTarget:self action:@selector(GoBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    
    [Gobtn setTitle:@"Go" forState:UIControlStateNormal];
    [Gobtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //[Gobtn setBackgroundImage:[UIImage imageNamed:@"okay-button.png"] forState:UIControlStateNormal];
    [Gobtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"okay-button" ofType:@"png"]] forState:UIControlStateNormal];
    
    [EditProductBackView addSubview:Gobtn];
    
     if (!displaylbl)
    displaylbl=[[UILabel alloc] init];
    displaylbl.frame=CGRectMake(Deptlbl.frame.size.width+SearchField.frame.size.width+5,5,SW, 40);
    [displaylbl setFont:[UIFont systemFontOfSize:20.0f]];
    [displaylbl setBackgroundColor:[UIColor clearColor]];
    [displaylbl setTextColor:[UIColor whiteColor]];
    [displaylbl setText:@"Display No of Sets"];
    [displaylbl setTextAlignment:NSTextAlignmentLeft];
    [EditProductBackView addSubview:displaylbl];
    
    
    NSString *invCountSQL = [NSString stringWithFormat:@"select count(*) as totalcount from inventorytable"];
    NSMutableArray *countArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:invCountSQL resultsArray:countArray];
    ////NSLog(@"count %@",countArray);
    NSDictionary *dict=[countArray objectAtIndex:0];
    
    int inventorycount=[[dict objectForKey:@"totalcount"] intValue];
    [productPaginationObject  ResultsPerset:inventorycount];
  
    ResultspersetBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    ResultspersetBtn.frame=CGRectMake(Deptlbl.frame.size.width+SearchField.frame.size.width+5+displaylbl.frame.size.width,5,SW, 40);
    [ResultspersetBtn addTarget:self action:@selector(ResultspersetBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    if ([[productPaginationObject  ResultspersetArray] count]>0) {
        [ResultspersetBtn setTitle:[[productPaginationObject  ResultspersetArray] objectAtIndex:0] forState:UIControlStateNormal];
    }
    
    [ResultspersetBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[ResultspersetBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [ResultspersetBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [EditProductBackView addSubview:ResultspersetBtn];

    
     //if (!DisplaySettable)
    DisplaySettable = [[UITableView alloc] initWithFrame:CGRectMake(Deptlbl.frame.size.width+SearchField.frame.size.width+5+displaylbl.frame.size.width,45,SW, 80) style:UITableViewStylePlain];
    DisplaySettable.backgroundColor=[UIColor whiteColor];
    DisplaySettable.delegate = self;
    DisplaySettable.dataSource = self;
    DisplaySettable.scrollEnabled = YES;
    DisplaySettable.hidden=YES;
    [DisplaySettable.layer setBorderWidth: 1.0];
    [DisplaySettable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [EditProductBackView addSubview:DisplaySettable];
    
 
    NSString  *strp=[NSString stringWithFormat:@"%@",ResultspersetBtn.titleLabel.text];
    
    NSArray *array=[strp componentsSeparatedByString:@"-"];
    
    strp=[array objectAtIndex:0];
   // // //NSLog(@"string value %@",strp);
    int str=[strp intValue];
    
    NSString *selectsql=[NSString stringWithFormat:@"SELECT inventary_department,inventory_item_no,inventary_item_name FROM inventorytable limit 50 offset %d",str-1];
    // // //NSLog(@" seletced query %@",selectsql);
    NSMutableArray *productArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:selectsql resultsArray:productArray];
        selectsql=nil;strp=nil;
    
    NSMutableArray *rdarray=productArray;
    [productPaginationObject  setCompleteresultset:rdarray];
    
    [productPaginationObject   paginationinitializer:rdarray :10];
    
    [productPaginationObject  paginationsegment].tintColor=[UIColor whiteColor];
    
    [[productPaginationObject  paginationsegment] setFrame:CGRectMake(0,140 ,EditProductBackView.frame.size.width, 40)];
    
    [[productPaginationObject  paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
        rdarray=nil;
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [productPaginationObject  paginationsegment].selectedSegmentIndex=selectedsegindex;
   [productPaginationObject  activateResults:selectedsegindex];
    
    [EditProductBackView addSubview:[productPaginationObject  paginationsegment]];
    
     if (!editProductTable)
    editProductTable=[[UITableView alloc]init];
    //[editProductTable  setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    [editProductTable setBackgroundColor:[UIColor clearColor]];
    editProductTable.frame=CGRectMake(0,180 ,EditProductBackView.frame.size.width, EditProductBackView.frame.size.height-180);
    
    //editProductTable.contentSize = CGSizeMake(ProductView.frame.size.width+1000, ProductView.frame.size.height+1000);
    editProductTable.delegate=self;
    editProductTable.dataSource=self;
    
    [EditProductBackView addSubview:editProductTable];
    
    [ItemNumberField setReturnKeyType:UIReturnKeyNext];
    [ItemNameField setReturnKeyType:UIReturnKeyNext];
    [DescriptionText setReturnKeyType:UIReturnKeyNext];
    [CostField setReturnKeyType:UIReturnKeyNext];
    [PriceyouChargeField setReturnKeyType:UIReturnKeyNext];
    [InStockField setReturnKeyType:UIReturnKeyDone];
    array=nil,array2=nil,array3=nil;
    paddingview=nil,paddingview2=nil,paddingview3=nil,paddingview4=nil,paddingview5=nil,paddingview10=nil;
}
-(void)AddProductClicked
{
    AddProductBtn.selected=YES;
    EditProductBtn.selected=NO;
    [editProductTable removeFromSuperview];
    [[productPaginationObject  paginationsegment] removeFromSuperview];
    [EditProductBackView removeFromSuperview];
    [ProductView addSubview:AddProductScrollView];
    
    
    SkusArray=[[NSMutableArray alloc]init];
    modifierNamesArray=[[NSMutableArray alloc]init];
    ModifierItemNosArray=[[NSMutableArray alloc]init];
    
    SelectedOpVendorsArray=[[NSMutableArray alloc] init];
    VendorPartsArray=[[NSMutableArray alloc] init];
    CostpersArray=[[NSMutableArray alloc] init];
    CasecostsArray=[[NSMutableArray alloc] init];
    NumberincasesArray=[[NSMutableArray alloc] init];
    preferredsArray=[[NSMutableArray alloc] init];
    
    ProductDepartmentsArray=Nil;
    ItemNumbersArray=Nil;
    ItemnameArray=nil;
    productDesArray=nil;
    CostArray=nil;
    priceyouchargeArray=nil;
    pricewithTaxArray=nil;
    InstockArray=nil;
    productVendorsArray=nil;
    taxvaluesArray=nil;
    productNotesArray=nil;
    
    VendorpartNosArray=nil;
    
    
    
}
-(void)EditProductClicked
{
    AddProductBtn.selected=NO;
    EditProductBtn.selected=YES;
    
    [AddProductScrollView removeFromSuperview];
    
    NSString *invCountSQL = [NSString stringWithFormat:@"select count(*) as totalcount from inventorytable"];
    NSMutableArray *countArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:invCountSQL resultsArray:countArray];
    ////NSLog(@"count %@",countArray);
    NSDictionary *dict=[countArray objectAtIndex:0];
    
    int inventorycount=[[dict objectForKey:@"totalcount"] intValue];
    [productPaginationObject  ResultsPerset:inventorycount];
    if (inventorycount>0)
    {
        [ResultspersetBtn setTitle:[[productPaginationObject  ResultspersetArray] objectAtIndex:0] forState:UIControlStateNormal];
    }
    [DisplaySettable reloadData];
    NSString  *strp=[NSString stringWithFormat:@"%@",ResultspersetBtn.titleLabel.text];
    
    NSArray *array=[strp componentsSeparatedByString:@"-"];
    
    strp=[array objectAtIndex:0];
    //// //NSLog(@"string value %@",strp);
    int str=[strp intValue];
    
    NSString *selectsql=[NSString stringWithFormat:@"SELECT inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id FROM inventorytable limit 50 offset %d",str-1];
    // // //NSLog(@" seletced query %@",selectsql);
    NSMutableArray *productArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:selectsql resultsArray:productArray];
    
    NSMutableArray *rdarray=productArray;
    
    //NSMutableArray *updateTableArray3=[[NSMutableArray alloc] init];
    
    [productPaginationObject  setCompleteresultset:rdarray];
    
    [productPaginationObject   paginationinitializer:rdarray :10];
    
    [productPaginationObject  paginationsegment].tintColor=[UIColor whiteColor];
    [[productPaginationObject  paginationsegment] setFrame:CGRectMake(0,140 ,EditProductBackView.frame.size.width, 40)];
    
    [[productPaginationObject  paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
    
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [productPaginationObject  paginationsegment].selectedSegmentIndex=selectedsegindex;
    [productPaginationObject  activateResults:selectedsegindex];
    [EditProductBackView addSubview:[productPaginationObject  paginationsegment]];
    
    [self getVendorpartnumberMethod];
    
    [EditProductBackView addSubview:editProductTable];
    
    
    [ProductView addSubview:EditProductBackView];
    // [editProductTable reloadData];
    
    
    [self productRelatedDataMethod];
    
    
    SkusArray=Nil;
    ModifierItemNosArray=nil;
    modifierNamesArray=nil;
    
    preferredsArray=nil;
    CostpersArray=nil;
    CasecostsArray=nil;
    NumberincasesArray=nil;
    VendorPartsArray=nil;
    SelectedOpVendorsArray=nil;
    
}
-(void)removeallCategoryArraysMethod
{
    [categoryIdsArray removeAllObjects],[categorynamesArray removeAllObjects],[categoryDesArray removeAllObjects];
    categoryIdsArray=nil,categorynamesArray=nil,categoryDesArray=nil;
}
-(void)removeallDeptsArraysMethod
{
    [departmentIDsArray removeAllObjects],[DepartmentDesArray removeAllObjects],[DepartmentNamesArray removeAllObjects],[DeptCatIdsArray removeAllObjects],[deptprintersArray removeAllObjects],[deptfoodsArray removeAllObjects],[depttaxesArray removeAllObjects];departmentIDsArray=nil,DepartmentNamesArray=nil,DepartmentDesArray=nil,DeptCatIdsArray=nil,deptprintersArray=nil,deptfoodsArray=nil,depttaxesArray=nil;[PrinterslistArray removeAllObjects],[MinitsArray removeAllObjects];
    PrinterslistArray=nil;
    MinitsArray=nil; [TimesArray removeAllObjects];
    TimesArray=nil;
}
-(void)removeallvendorArraysMethod
{
    [VendornumbersArray removeAllObjects],[termsArray removeAllObjects],[minimumorderArray removeAllObjects],[companyNAmesArray removeAllObjects],[flatrentsArray removeAllObjects],[TaxidsArray removeAllObjects],[billablesArray removeAllObjects],[socialsArray removeAllObjects],[podeliverysArray removeAllObjects],[streetaddressArray removeAllObjects],[exteddedArray removeAllObjects],[streetsArray removeAllObjects],[citysArray removeAllObjects],[statesArray removeAllObjects],[ZipcodesArray removeAllObjects],[countrysArray removeAllObjects],[firstnamesArray removeAllObjects],[lastnamesArray removeAllObjects],[phnumbersArray removeAllObjects],[faxesArray removeAllObjects],[emailsArray removeAllObjects],[websitesArray removeAllObjects];
    
    VendornumbersArray=nil,termsArray=nil,minimumorderArray=nil,commission=nil,companyNAmesArray=nil,flatrentsArray=nil,TaxidsArray=nil,billablesArray=nil,socialsArray=nil,podeliverysArray=nil,streetaddressArray=nil,exteddedArray=nil,streetsArray=nil,citysArray=nil,statesArray=nil,ZipcodesArray=nil,countrysArray=nil,firstnamesArray=nil,lastnamesArray=nil,phnumbersArray=nil,faxesArray=nil,emailsArray=nil,websitesArray=nil;
}
-(void)removeAllproductArraysMethod
{
    [itemIDArray removeAllObjects],[itemNameArray removeAllObjects],[discountArray removeAllObjects],[taxArray removeAllObjects],[yourCostArray removeAllObjects],[avgArray removeAllObjects],[quantityArray removeAllObjects],[dateArray removeAllObjects];  [allSkusArray removeAllObjects],[SelectedSkusArray removeAllObjects]; [modifierItemsArray removeAllObjects],[CountthisitemsArray removeAllObjects],[allowbuybackArray removeAllObjects],[printonreciptArray removeAllObjects],[foodstampableArray removeAllObjects],[promptpricesArray removeAllObjects],[OptCommissionsArray removeAllObjects],[OpBonuspointsArray removeAllObjects],[OpBarcodesArray removeAllObjects],[OplocationsArray removeAllObjects],[OpunisizesArray removeAllObjects],[OpunittypesArray removeAllObjects],[OpcommisArray removeAllObjects]; [itemsListArray removeAllObjects];
    [ModifierItemNosArray removeAllObjects],[modifierNamesArray removeAllObjects],[NamesArray removeAllObjects],[Allmodifiers removeAllObjects],[selectedModifiers removeAllObjects],[SelectedNamesArray removeAllObjects];
    [ProductDepartmentsArray removeAllObjects],[ItemNumbersArray removeAllObjects],[ItemnameArray removeAllObjects],[productDesArray removeAllObjects],[CostArray removeAllObjects],[priceyouchargeArray removeAllObjects],[pricewithTaxArray removeAllObjects],[InstockArray removeAllObjects],[productVendorsArray removeAllObjects],[taxvaluesArray removeAllObjects];
    [OpVendorsArray removeAllObjects];
    [SelectedOpVendorsArray removeAllObjects];
    [VendorpartNosArray removeAllObjects];
    
    [VendorPartsArray removeAllObjects],[CostpersArray removeAllObjects],[CasecostsArray removeAllObjects],[NumberincasesArray removeAllObjects],[preferredsArray removeAllObjects];
}

-(void)Deparmentbtnclicked
{
    [self removeallCategoryArraysMethod];
    [self removeAllproductArraysMethod];
       [self removeallvendorArraysMethod];
    ProductBtn.selected=NO;
    CategoryBtn.selected=NO;
    VendorsBtn.selected=NO;
    DepartmentsBtn.selected=YES;
    //[DepartmentsBtn setBackgroundImage:btnGreyImg forState:UIControlStateSelected];
    
    
    NSArray *AddvendorsViewArray = AddvendorsView.subviews;
    for (int i = 0; i<[AddvendorsViewArray count]; i++) {
        UIView *vi =[AddvendorsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *vendorsViewArray = vendorsView.subviews;
    for (int i = 0; i<[vendorsViewArray count]; i++) {
        UIView *vi =[vendorsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [AddvendorsView removeFromSuperview],[vendorsView removeFromSuperview];
    
    NSArray *AddProductScrollViewArray = AddProductScrollView.subviews;
    for (int i = 0; i<[AddProductScrollViewArray count]; i++) {
        UIView *vi =[AddProductScrollViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *EditProductBackViewArray = EditProductBackView.subviews;
    for (int i = 0; i<[EditProductBackViewArray count]; i++) {
        UIView *vi =[EditProductBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *ProductViewArray = ProductView.subviews;
    for (int i = 0; i<[ProductViewArray count]; i++) {
        UIView *vi =[ProductViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditProductBackView removeFromSuperview],[AddProductScrollView removeFromSuperview],[ProductView removeFromSuperview];
    
    NSArray *addCategoryViewArray = addCategoryView.subviews;
    for (int i = 0; i<[addCategoryViewArray count]; i++) {
        UIView *vi =[addCategoryViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addCategoryBackViewArray = addCategoryBackView.subviews;
    for (int i = 0; i<[addCategoryBackViewArray count]; i++) {
        UIView *vi =[addCategoryBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addCategoryView removeFromSuperview],[addCategoryBackView removeFromSuperview];
    
    //department view
    
    categorynamesArray=[[NSMutableArray alloc]init];
    NSString *querySQL6 = [NSString stringWithFormat: @"SELECT category_id FROM category_details"];
    NSMutableArray *categorysArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL6 resultsArray:categorysArray];
    
    for (NSDictionary *myDict in categorysArray)
    {
        
        NSString *catname=[myDict objectForKey:@"category_id"];
        
        [categorynamesArray addObject:catname];
        
    }
    //// //NSLog(@"%@ names",categorynamesArray);
    
    if(!depertmentView)
        depertmentView=[[UIView alloc]init];
    depertmentView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
    [depertmentView setBackgroundColor:[UIColor whiteColor]];
    [depertmentView.layer setBorderWidth: 1.0];
    [depertmentView.layer setCornerRadius:8.0f];
    [depertmentView.layer setMasksToBounds:YES];
    [depertmentView.layer setBorderColor:[[UIColor blackColor] CGColor]];
    
    depertmentView.layer.cornerRadius=8;
    [mainview addSubview:depertmentView];
    
    @autoreleasepool {
        addDeptbtn=[UIButton buttonWithType:UIButtonTypeCustom];
        [addDeptbtn setTitle:@"Add Department" forState:UIControlStateNormal];
        
        CGFloat addbuttonwidth2=(depertmentView.frame.size.width-10)/2;
        addDeptbtn.frame=CGRectMake(10, 10, addbuttonwidth2, 40);
        [addDeptbtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateSelected];
        [addDeptbtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [addDeptbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
        // [addDeptbtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bluetabactive" ofType:@"png"]] forState:UIControlStateNormal];
        addDeptbtn.selected=YES;
        //addtaxBtn.layer.cornerRadius=8;
        [addDeptbtn addTarget:self action:@selector(addDeptbtnClicked) forControlEvents:UIControlEventTouchUpInside];
        [depertmentView addSubview:addDeptbtn];
        Editdeptbtn=[UIButton buttonWithType:UIButtonTypeCustom];
        
        [Editdeptbtn setTitle:@"View & Edit Department" forState:UIControlStateNormal];
        Editdeptbtn.frame=CGRectMake(addDeptbtn.frame.size.width, 10, addbuttonwidth2, 40);
        //EditCategoryBtn.backgroundColor=[UIColor colorWithRed:203.0f green:203.0f/255.0f blue:203.0f/255.0f alpha:1.0f];
        Editdeptbtn.selected=NO;
        [Editdeptbtn setBackgroundColor:[UIColor whiteColor]];
        [Editdeptbtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateSelected];
        [Editdeptbtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [Editdeptbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
        [Editdeptbtn addTarget:self action:@selector(editDeptbtnClicked) forControlEvents:UIControlEventTouchUpInside];
        [depertmentView addSubview:Editdeptbtn];
    }
    //add department view
    if(!addDepartmentView)
        addDepartmentView=[[UIScrollView alloc]init];
    
    addDepartmentView.frame=CGRectMake(10, addDeptbtn.frame.size.height+10, depertmentView.frame.size.width-20, depertmentView.frame.size.height-20-addDeptbtn.frame.size.height);
    [addDepartmentView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    addDepartmentView.contentSize=CGSizeMake(depertmentView.frame.size.width-20, depertmentView.frame.size.height+300);
    //addDepartmentView.layer.cornerRadius=8;
    [depertmentView addSubview:addDepartmentView];
    
    
    CGFloat labelwidth=(addDepartmentView.frame.size.width)/2;
    CGFloat x=(labelwidth/2);
    if(!deptcatidlbl)
        deptcatidlbl=[[UILabel alloc]init];
    deptcatidlbl.frame=CGRectMake(x-100,60 ,350, 50);
    [deptcatidlbl setText:@"Category for this Department"];
    [deptcatidlbl setFont:[UIFont systemFontOfSize:25.0f]];
    [deptcatidlbl setBackgroundColor:[UIColor clearColor]];
    [deptcatidlbl setTextColor:[UIColor whiteColor]];
    [addDepartmentView addSubview:deptcatidlbl];
    
    if(!CatforthisDeptBtn)
        CatforthisDeptBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    CatforthisDeptBtn.frame=CGRectMake(x+260, 70, 200, 40);
    [CatforthisDeptBtn addTarget:self action:@selector(CategoryforthisDept) forControlEvents:UIControlEventTouchUpInside];
    [CatforthisDeptBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[CatforthisDeptBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    
    [CatforthisDeptBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    
    [addDepartmentView addSubview:CatforthisDeptBtn];
    if(!categorysListTable)
    categorysListTable = [[UITableView alloc] initWithFrame:CGRectMake(x+260, 110,200,100) style:UITableViewStylePlain];
    categorysListTable.backgroundColor=[UIColor whiteColor];
    categorysListTable.delegate = self;
    categorysListTable.dataSource = self;
    categorysListTable.scrollEnabled = YES;
    categorysListTable.hidden=YES;
    [categorysListTable.layer setBorderWidth: 1.0];
    [categorysListTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [addDepartmentView addSubview:categorysListTable];
    [categorysListTable reloadData];
    if(!deptIDlbl)
        deptIDlbl=[[UILabel alloc]init];
    deptIDlbl.frame=CGRectMake(x-40,150 ,250, 50);
    [deptIDlbl setText:@"Department ID"];
    [deptIDlbl setFont:[UIFont systemFontOfSize:25.0f]];
    [deptIDlbl setBackgroundColor:[UIColor clearColor]];
    [deptIDlbl setTextColor:[UIColor whiteColor]];
    [addDepartmentView addSubview:deptIDlbl];
    if(!IDfield)
        IDfield=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    IDfield.frame=CGRectMake(x+deptIDlbl.frame.size.width+10, 160, 200, 40);
    IDfield.delegate=self;
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    IDfield.leftView = paddingview;
    IDfield.leftViewMode = UITextFieldViewModeAlways;
    IDfield.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    //[IDfield setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [IDfield setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [IDfield setAutocorrectionType:UITextAutocorrectionTypeNo];
    [addDepartmentView addSubview:IDfield];
    [paddingview removeFromSuperview],paddingview=nil;
    if(!deptdesLbl)
        deptdesLbl=[[UILabel alloc]init];
    deptdesLbl.frame=CGRectMake(x-40,250 ,280, 50);
    [deptdesLbl setText:@"Department Description"];
    [deptdesLbl setBackgroundColor:[UIColor clearColor]];
    [deptdesLbl setFont:[UIFont systemFontOfSize:25.0f]];
    [deptdesLbl setTextColor:[UIColor whiteColor]];
    [addDepartmentView addSubview:deptdesLbl];
    if(!deptDestextView)
        deptDestextView=[[UITextView alloc] init];
    deptDestextView.frame=CGRectMake(x+deptIDlbl.frame.size.width+10, 230, 200, 100);
    deptDestextView.delegate=self;
    deptDestextView.font=[UIFont systemFontOfSize:14.0f];
    
    [deptDestextView setAutocorrectionType:UITextAutocorrectionTypeNo];
    
    deptDestextView.layer.cornerRadius=8;
    
    [addDepartmentView addSubview:deptDestextView];
    if(!Deptprinterlbl)
        Deptprinterlbl=[[UILabel alloc]init];
    Deptprinterlbl.frame=CGRectMake(x-40,350 ,280, 50);
    [Deptprinterlbl setText:@"Printer"];
    [Deptprinterlbl setBackgroundColor:[UIColor clearColor]];
    [Deptprinterlbl setFont:[UIFont systemFontOfSize:25.0f]];
    [Deptprinterlbl setTextColor:[UIColor whiteColor]];
    [addDepartmentView addSubview:Deptprinterlbl];
    
    NSString *querySQL5 = [NSString stringWithFormat:@"SELECT print_id FROM printer"];
    PrinterslistArray=[[NSMutableArray alloc]init];
    NSMutableArray *printerArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL5 resultsArray:printerArray];
    [PrinterslistArray addObject:@"--Select--"];
    if ([printerArray count]>0)
    {
        for (NSDictionary *Dict in printerArray)
        {
            [PrinterslistArray addObject:[Dict objectForKey:@"print_id"]];
        }
    }
    if(!DeptprinterBtn)
        DeptprinterBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    DeptprinterBtn.frame=CGRectMake(x+260, 360, 200, 40);
    [DeptprinterBtn addTarget:self action:@selector(DeptprinterClicked) forControlEvents:UIControlEventTouchUpInside];
    [DeptprinterBtn setTitle:[PrinterslistArray objectAtIndex:0] forState:UIControlStateNormal];
    [DeptprinterBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DeptprinterBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [DeptprinterBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [addDepartmentView addSubview:DeptprinterBtn];
    
   
    
    if(!PrinterslistTable)
        PrinterslistTable = [[UITableView alloc] initWithFrame:CGRectMake(x+260, 260,200,100) style:UITableViewStylePlain];
    PrinterslistTable.backgroundColor=[UIColor whiteColor];
    PrinterslistTable.delegate = self;
    PrinterslistTable.dataSource = self;
    PrinterslistTable.scrollEnabled = YES;
    PrinterslistTable.hidden=YES;
    [PrinterslistTable.layer setBorderWidth: 1.0];
    [PrinterslistTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [addDepartmentView addSubview:PrinterslistTable];
    if(!DeptFoodstampablelbl)
        DeptFoodstampablelbl=[[UILabel alloc]init];
    DeptFoodstampablelbl.frame=CGRectMake(x-40,400 ,280, 50);
    [DeptFoodstampablelbl setText:@"Foddstampable"];
    [DeptFoodstampablelbl setBackgroundColor:[UIColor clearColor]];
    [DeptFoodstampablelbl setFont:[UIFont systemFontOfSize:25.0f]];
    [DeptFoodstampablelbl setTextColor:[UIColor whiteColor]];
    [addDepartmentView addSubview:DeptFoodstampablelbl];
    if(!DeptfoodstampleBtn)
        DeptfoodstampleBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    DeptfoodstampleBtn.frame=CGRectMake(x+260, 410, 30, 30);
    [DeptfoodstampleBtn addTarget:self action:@selector(FoodstampableClicked) forControlEvents:UIControlEventTouchUpInside];
    [DeptfoodstampleBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DeptfoodstampleBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [DeptfoodstampleBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    //[DeptfoodstampleBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [DeptfoodstampleBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    [addDepartmentView addSubview:DeptfoodstampleBtn];
    
    if(!Deptax1Btn)
        Deptax1Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    Deptax1Btn.frame=CGRectMake(x-60,460,30, 30);
    [Deptax1Btn addTarget:self action:@selector(DeptTax1Clicked) forControlEvents:UIControlEventTouchUpInside];
    [Deptax1Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    // [Deptax1Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[Deptax1Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    
    [Deptax1Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    //[DeptfoodstampleBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [Deptax1Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    [addDepartmentView addSubview:Deptax1Btn];
    if(!Deptax1lbl)
        Deptax1lbl=[[UILabel alloc] init];
    Deptax1lbl.frame=CGRectMake(x+35-60,455,50, 40);
    [Deptax1lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Deptax1lbl setBackgroundColor:[UIColor clearColor]];
    [Deptax1lbl setTextColor:[UIColor whiteColor]];
    Deptax1Btn.selected=YES;
    [Deptax1lbl setText:tax1Name];
    
    [Deptax1lbl setTextAlignment:NSTextAlignmentLeft];
    [addDepartmentView addSubview:Deptax1lbl];
    if(!Deptax2Btn)
        Deptax2Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    Deptax2Btn.frame=CGRectMake(x+75+Deptax1lbl.frame.size.width-40,460,30, 30);
    [Deptax2Btn addTarget:self action:@selector(DeptTax2Clikced) forControlEvents:UIControlEventTouchUpInside];
    [Deptax2Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[Deptax2Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[Deptax2Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [Deptax2Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    //[DeptfoodstampleBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [Deptax2Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [addDepartmentView addSubview:Deptax2Btn];
    if(!Deptax2lbl)
        Deptax2lbl=[[UILabel alloc] init];
    Deptax2lbl.frame=CGRectMake(x+65+Deptax1lbl.frame.size.width+45-40,455,50, 40);
    [Deptax2lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Deptax2lbl setBackgroundColor:[UIColor clearColor]];
    [Deptax2lbl setTextColor:[UIColor whiteColor]];
    
    [Deptax2lbl setText:tax2Name];
    
    [Deptax2lbl setTextAlignment:NSTextAlignmentLeft];
    [addDepartmentView addSubview:Deptax2lbl];
    if(!Deptax3Btn)
        Deptax3Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    Deptax3Btn.frame=CGRectMake(x+75+Deptax1lbl.frame.size.width+45-20+Deptax2lbl.frame.size.width,460,30, 30);
    [Deptax3Btn addTarget:self action:@selector(DeptTax3Clicked) forControlEvents:UIControlEventTouchUpInside];
    [Deptax3Btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[Deptax3Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[Deptax3Btn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    
    [Deptax3Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    //[DeptfoodstampleBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [Deptax3Btn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    [addDepartmentView addSubview:Deptax3Btn];
    if(!Deptax3lbl)
        Deptax3lbl=[[UILabel alloc] init];
    Deptax3lbl.frame=CGRectMake(x+65+Deptax1lbl.frame.size.width+45-20+Deptax2lbl.frame.size.width+45,455,50, 40);
    [Deptax3lbl setFont:[UIFont systemFontOfSize:20.0f]];
    [tax3lbl setBackgroundColor:[UIColor clearColor]];
    [Deptax3lbl setTextColor:[UIColor whiteColor]];
    
    [Deptax3lbl setText:tax3Name];
    
    [Deptax3lbl setTextAlignment:NSTextAlignmentLeft];
    [addDepartmentView addSubview:Deptax3lbl];
    if(!DepBarTaxBtn)
        DepBarTaxBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    DepBarTaxBtn.frame=CGRectMake(x+75+Deptax1lbl.frame.size.width+45+Deptax2lbl.frame.size.width+45+Deptax3lbl.frame.size.width,460,30, 30);
    [DepBarTaxBtn addTarget:self action:@selector(DeptBarBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [DepBarTaxBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DepBarTaxBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    //[DepBarTaxBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    
    [DepBarTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
    //[DeptfoodstampleBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
    [DepBarTaxBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
    [addDepartmentView addSubview:DepBarTaxBtn];
    if(!Depbartaxlbl)
        Depbartaxlbl=[[UILabel alloc] init];
    Depbartaxlbl.frame=CGRectMake(x+65+Deptax1lbl.frame.size.width+45+Deptax2lbl.frame.size.width+45+Deptax3lbl.frame.size.width+45,455,80, 40);
    [Depbartaxlbl setFont:[UIFont systemFontOfSize:18.0f]];
    [Depbartaxlbl setBackgroundColor:[UIColor clearColor]];
    [Depbartaxlbl setTextColor:[UIColor whiteColor]];
    [Depbartaxlbl setText:@"Bartax"];
    [Depbartaxlbl setTextAlignment:NSTextAlignmentLeft];
    [addDepartmentView addSubview:Depbartaxlbl];
    
    Deptfoodstampable=@"NO";
    DepTaxValueStr=tax1Name;
    if(!TimeForDeptlbl)
        TimeForDeptlbl=[[UILabel alloc]init];
    TimeForDeptlbl.frame=CGRectMake(x-100,520 ,350, 50);
    [TimeForDeptlbl setText:@"Time for Department Printer"];
    [TimeForDeptlbl setFont:[UIFont systemFontOfSize:25.0f]];
    [TimeForDeptlbl setBackgroundColor:[UIColor clearColor]];
    [TimeForDeptlbl setTextColor:[UIColor whiteColor]];
    [addDepartmentView addSubview:TimeForDeptlbl];
    if(!MinitBtn)
        MinitBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    MinitBtn.frame=CGRectMake(x+260,520, 100, 40);
    [MinitBtn addTarget:self action:@selector(minitsBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [MinitBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[MinitBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [MinitBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [MinitBtn setTitle:@"Minit" forState:UIControlStateNormal];
    [addDepartmentView addSubview:MinitBtn];
    if(!MinitslistTable)
        MinitslistTable = [[UITableView alloc] initWithFrame:CGRectMake(x+260, 560,100,100) style:UITableViewStylePlain];
    MinitslistTable.backgroundColor=[UIColor whiteColor];
    MinitslistTable.delegate = self;
    MinitslistTable.dataSource = self;
    MinitslistTable.scrollEnabled = YES;
    MinitslistTable.hidden=YES;
    [MinitslistTable.layer setBorderWidth: 1.0];
    [MinitslistTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [addDepartmentView addSubview:MinitslistTable];
    if(!SecsBtn)
        SecsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    SecsBtn.frame=CGRectMake(x+370, 520, 100, 40);
    [SecsBtn addTarget:self action:@selector(SecsBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [SecsBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[SecsBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [SecsBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    [SecsBtn setTitle:@"Secs" forState:UIControlStateNormal];
    [addDepartmentView addSubview:SecsBtn];
    if(!SecslistTable)
        SecslistTable = [[UITableView alloc] initWithFrame:CGRectMake(x+370, 560, 100, 100) style:UITableViewStylePlain];
    SecslistTable.backgroundColor=[UIColor whiteColor];
    SecslistTable.delegate = self;
    SecslistTable.dataSource = self;
    SecslistTable.scrollEnabled = YES;
    SecslistTable.hidden=YES;
    [SecslistTable.layer setBorderWidth: 1.0];
    [SecslistTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [addDepartmentView addSubview:SecslistTable];
    @autoreleasepool {
        savedeptBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        savedeptBtn.frame=CGRectMake(x+deptIDlbl.frame.size.width-180, 620, 80, 30);
        [savedeptBtn addTarget:self action:@selector(SaveDeptData) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [savedeptBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[savedeptBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [savedeptBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        
        [addDepartmentView addSubview:savedeptBtn];
        
        canceldeptbtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        canceldeptbtn.frame=CGRectMake(x+deptIDlbl.frame.size.width-20, 620, 80, 30);
        [canceldeptbtn addTarget:self action:@selector(CancelDeptData) forControlEvents:UIControlEventTouchUpInside];
        [canceldeptbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[canceldeptbtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        [canceldeptbtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [addDepartmentView addSubview:canceldeptbtn];
    }
    
    if (!MinitsArray)
        MinitsArray=[[NSMutableArray alloc]initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24",@"25",@"26",@"27",@"28",@"29",@"30",@"31",@"32",@"33",@"34",@"35",@"36",@"37",@"38",@"39",@"40",@"41",@"42",@"43",@"44",@"45",@"46",@"47",@"48",@"49",@"50",@"51",@"52",@"53",@"54",@"55",@"56",@"57",@"58",@"59",nil];
    
    
    //edit dept view
    
    NSString *querySQL7 = [NSString stringWithFormat:@"SELECT department_id,department_description,category_id,department_foodstampable,department_totaltax,check_value FROM department_details"];
    NSMutableArray *deptsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:deptsArray];
    
    NSMutableArray *rdarray=deptsArray;
    
    //updateTableArray2=[[NSMutableArray alloc] init];
    
    [jobpaginationObject setCompleteresultset:rdarray];
    
    [jobpaginationObject  paginationinitializer:rdarray :10];
    
    [jobpaginationObject paginationsegment].tintColor=[UIColor whiteColor];
    [[jobpaginationObject paginationsegment] setFrame:CGRectMake(10, addDeptbtn.frame.size.height+10,depertmentView.frame.size.width-20, 40)];
    
    [[jobpaginationObject paginationsegment] addTarget:self action:@selector(segmentchanged2:) forControlEvents:UIControlEventValueChanged];
    
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [jobpaginationObject paginationsegment].selectedSegmentIndex=selectedsegindex;
    updateTableArray2=[jobpaginationObject activateResults:selectedsegindex];
    if (!EditDeptTable)
        EditDeptTable=[[UITableView alloc]init];
    [EditDeptTable  setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    EditDeptTable.frame=CGRectMake(10, addDeptbtn.frame.size.height+50, depertmentView.frame.size.width-20, depertmentView.frame.size.height-20-addDeptbtn.frame.size.height-40);
    EditDeptTable.delegate=self;
    EditDeptTable.dataSource=self;
    updateTableArray2=nil,rdarray=nil;
    
}
-(void)addDeptbtnClicked
{
    
    Editdeptbtn.selected=NO;
    addDeptbtn.selected=YES;
    
    [EditDeptTable removeFromSuperview];
    [[jobpaginationObject paginationsegment] removeFromSuperview];
    
    [depertmentView addSubview:addDepartmentView];
    
    DepartmentNamesArray=nil;
    departmentIDsArray=nil;
    DepartmentDesArray=nil;
    DeptCatIdsArray=nil;
    deptfoodsArray=nil;
    depttaxesArray=nil;
    
}
-(void)editDeptbtnClicked
{
    
    NSString *querySQL7 = [NSString stringWithFormat:@"SELECT department_id,department_description,category_id,department_foodstampable,department_totaltax,check_value FROM department_details"];
    NSMutableArray *deptsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:deptsArray];
    
    NSMutableArray *rdarray=deptsArray;
    
    [jobpaginationObject setCompleteresultset:rdarray];
    
    [jobpaginationObject  paginationinitializer:rdarray :10];
    
    [jobpaginationObject paginationsegment].tintColor=[UIColor whiteColor];
    [[jobpaginationObject paginationsegment] setFrame:CGRectMake(10, addDeptbtn.frame.size.height+10,depertmentView.frame.size.width-20, 40)];
    
    [[jobpaginationObject paginationsegment] addTarget:self action:@selector(segmentchanged2:) forControlEvents:UIControlEventValueChanged];
    
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [jobpaginationObject paginationsegment].selectedSegmentIndex=selectedsegindex;
    updateTableArray2=[jobpaginationObject activateResults:selectedsegindex];
    
    addDeptbtn.selected=NO;
    Editdeptbtn.selected=YES;
    
    [addDepartmentView removeFromSuperview];
    [depertmentView addSubview:[jobpaginationObject paginationsegment]];
    [depertmentView addSubview:EditDeptTable];
    
    rdarray=nil,updateTableArray2=nil;
    [self DeptDataMethod];
    
}
-(void)categoryBtnclicked
{
    [self removeallDeptsArraysMethod];
       [self removeallvendorArraysMethod];
     [self removeAllproductArraysMethod];
    //CategoryBtn.selected=NO;
    DepartmentsBtn.selected=NO;
    VendorsBtn.selected=NO;
    ProductBtn.selected=NO;
    CategoryBtn.selected=YES;
    
    NSArray *AddvendorsViewArray = AddvendorsView.subviews;
    for (int i = 0; i<[AddvendorsViewArray count]; i++) {
        UIView *vi =[AddvendorsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *vendorsViewArray = vendorsView.subviews;
    for (int i = 0; i<[vendorsViewArray count]; i++) {
        UIView *vi =[vendorsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [AddvendorsView removeFromSuperview],[vendorsView removeFromSuperview];
    
    NSArray *AddProductScrollViewArray = AddProductScrollView.subviews;
    for (int i = 0; i<[AddProductScrollViewArray count]; i++) {
        UIView *vi =[AddProductScrollViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *EditProductBackViewArray = EditProductBackView.subviews;
    for (int i = 0; i<[EditProductBackViewArray count]; i++) {
        UIView *vi =[EditProductBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *ProductViewArray = ProductView.subviews;
    for (int i = 0; i<[ProductViewArray count]; i++) {
        UIView *vi =[ProductViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditProductBackView removeFromSuperview],[AddProductScrollView removeFromSuperview],[ProductView removeFromSuperview];
    
    
    NSArray *addDepartmentViewArray = addDepartmentView.subviews;
    for (int i = 0; i<[addDepartmentViewArray count]; i++) {
        UIView *vi =[addDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *depertmentViewArray = depertmentView.subviews;
    for (int i = 0; i<[depertmentViewArray count]; i++) {
        UIView *vi =[depertmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addDepartmentView removeFromSuperview],[depertmentView removeFromSuperview];
    
    //category view
    if(!addCategoryBackView)
        addCategoryBackView=[[UIView alloc]init];
    addCategoryBackView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
    [addCategoryBackView setBackgroundColor:[UIColor whiteColor]];
    [addCategoryBackView.layer setBorderWidth: 1.0];
    [addCategoryBackView.layer setCornerRadius:8.0f];
    [addCategoryBackView.layer setMasksToBounds:YES];
    [addCategoryBackView.layer setBorderColor:[[UIColor blackColor] CGColor]];
    addCategoryBackView.layer.cornerRadius=8;
    [mainview addSubview:addCategoryBackView];
    @autoreleasepool {
        addcategoryBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        [addcategoryBtn setTitle:@"Add Category" forState:UIControlStateNormal];
        
        CGFloat addbuttonwidth=(addCategoryBackView.frame.size.width-10)/2;
        addcategoryBtn.frame=CGRectMake(10, 10, addbuttonwidth, 40);
        [addcategoryBtn addTarget:self action:@selector(addCategorybtnClicked) forControlEvents:UIControlEventTouchUpInside];
        [addcategoryBtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateSelected];
        [addcategoryBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [addcategoryBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
        addcategoryBtn.selected=YES;
        [addCategoryBackView addSubview:addcategoryBtn];
        EditCategoryBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        
        [EditCategoryBtn setTitle:@"View & Edit Category" forState:UIControlStateNormal];
        EditCategoryBtn.frame=CGRectMake(addcategoryBtn.frame.size.width, 10, addbuttonwidth, 40);
        //EditCategoryBtn.backgroundColor=[UIColor colorWithRed:203.0f green:203.0f/255.0f blue:203.0f/255.0f alpha:1.0f];
        
        [EditCategoryBtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateSelected];
        [EditCategoryBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [EditCategoryBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
        [EditCategoryBtn setBackgroundColor:[UIColor whiteColor]];
        [EditCategoryBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        EditCategoryBtn.selected=NO;
        [EditCategoryBtn addTarget:self action:@selector(EditcategoryClicked) forControlEvents:UIControlEventTouchUpInside];
        [addCategoryBackView addSubview:EditCategoryBtn];
        
    }
    
    //add Tax view
    if(!addCategoryView)
        addCategoryView=[[UIScrollView alloc]init];
    
    //CGFloat addviewwidth=(TaxView.frame.size.width/2);
    //CGFloat x=addviewwidth/2-10;
    addCategoryView.frame=CGRectMake(10, addcategoryBtn.frame.size.height+10, addCategoryBackView.frame.size.width-20, addCategoryBackView.frame.size.height-20-addcategoryBtn.frame.size.height);
    [addCategoryView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    addCategoryView.contentSize=CGSizeMake(addCategoryBackView.frame.size.width-20, addCategoryBackView.frame.size.height+100);
    //addCategoryView.layer.cornerRadius=8;
    [addCategoryBackView addSubview:addCategoryView];
    
    CGFloat labelwidth=(addCategoryView.frame.size.width)/2;
    CGFloat x=(labelwidth/2);
    if(!catIDlbl)
        catIDlbl=[[UILabel alloc]init];
    catIDlbl.frame=CGRectMake(x-40,50 ,200, 50);
    [catIDlbl setText:@"Category ID"];
    [catIDlbl setFont:[UIFont systemFontOfSize:25.0f]];
    [catIDlbl setBackgroundColor:[UIColor clearColor]];
    [catIDlbl setTextColor:[UIColor whiteColor]];
    [addCategoryView addSubview:catIDlbl];
    if(!categoryidField)
        categoryidField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    categoryidField.frame=CGRectMake(x+catIDlbl.frame.size.width+30, 60, 200, 40);
    categoryidField.delegate=self;
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    categoryidField.leftView = paddingview;
    categoryidField.leftViewMode = UITextFieldViewModeAlways;
    categoryidField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    // [categoryidField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [categoryidField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [paddingview removeFromSuperview],paddingview=nil;
    
    [categoryidField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [addCategoryView addSubview:categoryidField];
    if(!catdesLbl)
        catdesLbl=[[UILabel alloc]init];
    catdesLbl.frame=CGRectMake(x-40,150 ,250, 50);
    [catdesLbl setText:@"Category Description"];
    [catdesLbl setBackgroundColor:[UIColor clearColor]];
    [catdesLbl setFont:[UIFont systemFontOfSize:25.0f]];
    [catdesLbl setTextColor:[UIColor whiteColor]];
    [addCategoryView addSubview:catdesLbl];
    if(!catDesField)
        catDesField=[[UITextView alloc] init];
    catDesField.frame=CGRectMake(x+catIDlbl.frame.size.width+30, 130, 200, 100);
    catDesField.delegate=self;
    catDesField.font=[UIFont systemFontOfSize:14.0f];
    //    UIView *paddingview2=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    //    catDesField.leftView = paddingview2;
    //    catDesField.leftViewMode = UITextFieldViewModeAlways;
    [catDesField setAutocorrectionType:UITextAutocorrectionTypeNo];
    //[RateTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    // [catDesField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    // catDesField.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed: @"addinputtextfield.png"]];
    catDesField.layer.cornerRadius=8;
    //[catDesField setKeyboardType:UIKeyboardTypeNumberPad];
    //catDesField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    [addCategoryView addSubview:catDesField];
    @autoreleasepool {
        saveCategoryBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        saveCategoryBtn.frame=CGRectMake(x+catdesLbl.frame.size.width-160, 260, 80, 30);
        [saveCategoryBtn addTarget:self action:@selector(SaveCategorydata) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [saveCategoryBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[saveCategoryBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [saveCategoryBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        [addCategoryView addSubview:saveCategoryBtn];
        
        cancelcatBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        cancelcatBtn.frame=CGRectMake(x+catdesLbl.frame.size.width-10, 260, 80, 30);
        [cancelcatBtn addTarget:self action:@selector(CancelCatedorydataClicked) forControlEvents:UIControlEventTouchUpInside];
        [cancelcatBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[cancelcatBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        [cancelcatBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        
        [addCategoryView addSubview:cancelcatBtn];
    }
    
    
    //edit cat view
    NSString *querySQL6 = [NSString stringWithFormat: @"SELECT category_id,category_description FROM category_details"];
    NSMutableArray *categorysArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL6 resultsArray:categorysArray];
    
    NSMutableArray *rdarray=categorysArray;
    
    //// //NSLog(@"%@",rdarray);
    //updateTableArray=[[NSMutableArray alloc] init];
    
    [paginationObject setCompleteresultset:rdarray];
    
    [paginationObject  paginationinitializer:rdarray :5];
    
    [paginationObject paginationsegment].tintColor=[UIColor whiteColor];
    [[paginationObject paginationsegment] setFrame:CGRectMake(10, addcategoryBtn.frame.size.height+10,addCategoryBackView.frame.size.width-20, 40)];
    
    [[paginationObject paginationsegment] addTarget:self action:@selector(segmentchanged:) forControlEvents:UIControlEventValueChanged];
    
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [paginationObject paginationsegment].selectedSegmentIndex=selectedsegindex;
    updateTableArray=[paginationObject activateResults:selectedsegindex];
    if(!editCategoryTable)
        editCategoryTable=[[UITableView alloc]init];
    [editCategoryTable  setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    editCategoryTable.frame=CGRectMake(10, addcategoryBtn.frame.size.height+50, addCategoryBackView.frame.size.width-20, addCategoryBackView.frame.size.height-20-addcategoryBtn.frame.size.height-40);
    editCategoryTable.delegate=self;
    editCategoryTable.dataSource=self;
    updateTableArray=nil,rdarray=nil;
    
}
-(void)addCategorybtnClicked
{
    addcategoryBtn.selected=YES;
    EditCategoryBtn.selected=NO;
    [editCategoryTable removeFromSuperview];
    [[paginationObject paginationsegment] removeFromSuperview];
    [addCategoryBackView addSubview:addCategoryView];
    
    categorynamesArray=nil;
    categoryIdsArray=nil;
    categoryDesArray=nil;
    
}
-(void)EditcategoryClicked
{
    NSString *querySQL6 = [NSString stringWithFormat: @"SELECT category_id,category_description FROM category_details"];
    NSMutableArray *categorysArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL6 resultsArray:categorysArray];
    
    NSMutableArray *rdarray=categorysArray;
    
    //// //NSLog(@"%@",rdarray);
    //updateTableArray=[[NSMutableArray alloc] init];
    
    [paginationObject setCompleteresultset:rdarray];
    
    [paginationObject  paginationinitializer:rdarray :5];
    
    [paginationObject paginationsegment].tintColor=[UIColor whiteColor];
    [[paginationObject paginationsegment] setFrame:CGRectMake(10, addcategoryBtn.frame.size.height+10,addCategoryBackView.frame.size.width-20, 40)];
    
    [[paginationObject paginationsegment] addTarget:self action:@selector(segmentchanged:) forControlEvents:UIControlEventValueChanged];
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [paginationObject paginationsegment].selectedSegmentIndex=selectedsegindex;
    updateTableArray=[paginationObject activateResults:selectedsegindex];
    [editCategoryTable reloadData];
    
    addcategoryBtn.selected=NO;
    EditCategoryBtn.selected=YES;
    
    [addCategoryView removeFromSuperview];
    [addCategoryBackView addSubview:[paginationObject paginationsegment]];
    [addCategoryBackView addSubview:editCategoryTable];
    
    [self getcategoryDatamethod];
    rdarray=nil,updateTableArray=nil;
    
}
-(void)vendorbtnclicked
{
    [self removeallCategoryArraysMethod];
    [self removeallDeptsArraysMethod];
     [self removeAllproductArraysMethod];
    CategoryBtn.selected=NO;
    ProductBtn.selected=NO;
    DepartmentsBtn.selected=NO;
    VendorsBtn.selected=YES;
    
    
    NSArray *AddProductScrollViewArray = AddProductScrollView.subviews;
    for (int i = 0; i<[AddProductScrollViewArray count]; i++) {
        UIView *vi =[AddProductScrollViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *EditProductBackViewArray = EditProductBackView.subviews;
    for (int i = 0; i<[EditProductBackViewArray count]; i++) {
        UIView *vi =[EditProductBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *ProductViewArray = ProductView.subviews;
    for (int i = 0; i<[ProductViewArray count]; i++) {
        UIView *vi =[ProductViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditProductBackView removeFromSuperview],[AddProductScrollView removeFromSuperview],[ProductView removeFromSuperview];
    
    NSArray *addCategoryViewArray = addCategoryView.subviews;
    for (int i = 0; i<[addCategoryViewArray count]; i++) {
        UIView *vi =[addCategoryViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addCategoryBackViewArray = addCategoryBackView.subviews;
    for (int i = 0; i<[addCategoryBackViewArray count]; i++) {
        UIView *vi =[addCategoryBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addCategoryView removeFromSuperview],[addCategoryBackView removeFromSuperview];
    
    NSArray *addDepartmentViewArray = addDepartmentView.subviews;
    for (int i = 0; i<[addDepartmentViewArray count]; i++) {
        UIView *vi =[addDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *depertmentViewArray = depertmentView.subviews;
    for (int i = 0; i<[depertmentViewArray count]; i++) {
        UIView *vi =[depertmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addDepartmentView removeFromSuperview],[depertmentView removeFromSuperview];
    
    
    //vendor view
    if(!vendorsView)
        vendorsView=[[UIView alloc]init];
    vendorsView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
    [vendorsView setBackgroundColor:[UIColor whiteColor]];
    vendorsView.layer.cornerRadius=8;
    [mainview addSubview:vendorsView];
    if(!AddvendorBtn)
        AddvendorBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    [AddvendorBtn setTitle:@"Add Vendor" forState:UIControlStateNormal];
    
    CGFloat addbuttonwidth3=(vendorsView.frame.size.width-5)/2;
    AddvendorBtn.frame=CGRectMake(5, 10, addbuttonwidth3, 40);
    //[AddvendorBtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
    
    
    [AddvendorBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bluetabactive" ofType:@"png"]] forState:UIControlStateSelected];
    [AddvendorBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [AddvendorBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
    AddvendorBtn.selected=YES;
    //addtaxBtn.layer.cornerRadius=8;
    [AddvendorBtn addTarget:self action:@selector(AddvendorClicked) forControlEvents:UIControlEventTouchUpInside];
    [vendorsView addSubview:AddvendorBtn];
    if(!EditvendorBtn)
        EditvendorBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    [EditvendorBtn setTitle:@"View & Edit Vendor" forState:UIControlStateNormal];
    EditvendorBtn.frame=CGRectMake(AddvendorBtn.frame.size.width, 10, addbuttonwidth3, 40);
    //EditCategoryBtn.backgroundColor=[UIColor colorWithRed:203.0f green:203.0f/255.0f blue:203.0f/255.0f alpha:1.0f];
    [EditvendorBtn setBackgroundColor:[UIColor whiteColor]];
    [EditvendorBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditvendorBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bluetabactive" ofType:@"png"]] forState:UIControlStateSelected];
    [EditvendorBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditvendorBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
    EditvendorBtn.selected=NO;
    [EditvendorBtn addTarget:self action:@selector(EditVendorClicked) forControlEvents:UIControlEventTouchUpInside];
    [vendorsView addSubview:EditvendorBtn];
    
    //add vendor view
    if(!AddvendorsView)
        AddvendorsView=[[UIScrollView alloc]init];
    AddvendorsView.frame=CGRectMake(5, AddvendorBtn.frame.size.height+10, vendorsView.frame.size.width-10, vendorsView.frame.size.height-20-AddvendorBtn.frame.size.height);
    [AddvendorsView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    AddvendorsView.contentSize=CGSizeMake(vendorsView.frame.size.width-10, vendorsView.frame.size.height-20-AddvendorBtn.frame.size.height+500);
    //AddvendorsView.layer.cornerRadius=8;
    [vendorsView addSubview:AddvendorsView];
    CGFloat fieldwidth=(AddvendorsView.frame.size.width-20)/4;
    CGFloat v=(fieldwidth/2);
    if(!InfotextLbl)
        InfotextLbl=[[UILabel alloc]init];
    InfotextLbl.frame=CGRectMake(v,5 ,350, 30);
    [InfotextLbl setText:@"General Information"];
    [InfotextLbl setFont:[UIFont systemFontOfSize:20.0f]];
    [InfotextLbl setBackgroundColor:[UIColor clearColor]];
    [InfotextLbl setTextColor:[UIColor whiteColor]];
    [AddvendorsView addSubview:InfotextLbl];
    if(!AddresstextLbl)
        AddresstextLbl=[[UILabel alloc]init];
    AddresstextLbl.frame=CGRectMake(v+InfotextLbl.frame.size.width+40,5 ,350, 30);
    [AddresstextLbl setText:@"Address"];
    [AddresstextLbl setFont:[UIFont systemFontOfSize:20.0f]];
    [AddresstextLbl setBackgroundColor:[UIColor clearColor]];
    [AddresstextLbl setTextColor:[UIColor whiteColor]];
    [AddvendorsView addSubview:AddresstextLbl];
    int d=40;
    ////NSLog(@"textfield width %f",fieldwidth);
    NSArray *labelArray;
    if (!labelArray)
        labelArray=[[NSArray alloc] initWithObjects:@"Vendor Number",@"Terms ",@"Minimum Order",@"Commission %",@"Company Name",@"Flat Rent Rate",@"Tax Id ",@"BillableDepartment",@"SocialSecurity",nil];
    for (int i=0; i<9; i++)
    {
        
        generalinfolbl=[[UILabel alloc] init];
        generalinfolbl.frame=CGRectMake(v-80, d,fieldwidth+10, 40);
        
        generalinfolbl.tag=i+100;
        [generalinfolbl setFont:[UIFont systemFontOfSize:20.0f]];
        [generalinfolbl setBackgroundColor:[UIColor clearColor]];
        [generalinfolbl setTextColor:[UIColor whiteColor]];
        [generalinfolbl setText:[labelArray objectAtIndex:i]];
        [generalinfolbl setTextAlignment:NSTextAlignmentLeft];
        [AddvendorsView addSubview:generalinfolbl];
        //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
        GeneralinfoField=[[UITextField alloc] init];
        //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
        GeneralinfoField.frame=CGRectMake(fieldwidth+5, d,fieldwidth-10, 40);
        GeneralinfoField.delegate=self;
        GeneralinfoField.tag=i+100;
        
        UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
        // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
        GeneralinfoField.leftView = paddingview;
        GeneralinfoField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
        GeneralinfoField.leftViewMode = UITextFieldViewModeAlways;
        //[GeneralinfoField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
        [GeneralinfoField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
        
        [GeneralinfoField addTarget:self action:@selector(GeneralinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
        [GeneralinfoField setAutocorrectionType:UITextAutocorrectionTypeNo];
        
        //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
        
        [AddvendorsView addSubview:GeneralinfoField];
        
        d=d+60;
        paddingview=nil;
    }
    // //NSLog(@"textfield width %f",fieldwidth);
    if(!polbl)
        polbl=[[UILabel alloc] init];
    polbl.frame=CGRectMake(v-80, 580,fieldwidth+10, 40);
    [polbl setFont:[UIFont systemFontOfSize:20.0f]];
    [polbl setBackgroundColor:[UIColor clearColor]];
    [polbl setTextColor:[UIColor whiteColor]];
    [polbl setText:@"PoDeliveryMethod"];
    [polbl setTextAlignment:NSTextAlignmentLeft];
    [AddvendorsView addSubview:polbl];
    if(!DeliverymethodBtn)
        DeliverymethodBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    DeliverymethodBtn.frame=CGRectMake(fieldwidth+5, 580, fieldwidth-10, 40);
    [DeliverymethodBtn addTarget:self action:@selector(DeliveryMethodbtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [DeliverymethodBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //[DeliverymethodBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
    [DeliverymethodBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    
    [AddvendorsView addSubview:DeliverymethodBtn];
    if(!DeliveryTypesTable)
        DeliveryTypesTable = [[UITableView alloc] initWithFrame:CGRectMake(fieldwidth+5, 620,fieldwidth-10,100) style:UITableViewStylePlain];
    DeliveryTypesTable.backgroundColor=[UIColor whiteColor];
    DeliveryTypesTable.delegate = self;
    DeliveryTypesTable.dataSource = self;
    DeliveryTypesTable.scrollEnabled = YES;
    DeliveryTypesTable.hidden=YES;
    [DeliveryTypesTable.layer setBorderWidth: 1.0];
    [DeliveryTypesTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [AddvendorsView addSubview:DeliveryTypesTable];
    if (!DeliverymethodsArray)
        DeliverymethodsArray=[[NSArray alloc]initWithObjects:@"Print",@"Fax",@"Email", nil];
    int h=40;
    NSArray *labelArray2;
    if (!labelArray2)
        labelArray2=[[NSArray alloc] initWithObjects:@"Street Address",@"Extended Address ",@"City",@"State",@"Zip Code",@"Country",@"First Name",@"Last Name",@"PhoneNumber",@"Fax Number",@"Email",@"Website",nil];
    for (int i=0; i<12; i++)
    {
        
        Addresslbl=[[UILabel alloc] init];
        Addresslbl.frame=CGRectMake(fieldwidth+GeneralinfoField.frame.size.width+15, h,fieldwidth+10, 40);
        
        Addresslbl.tag=i+100;
        [Addresslbl setFont:[UIFont systemFontOfSize:20.0f]];
        [Addresslbl setBackgroundColor:[UIColor clearColor]];
        [Addresslbl setTextColor:[UIColor whiteColor]];
        
        [Addresslbl setText:[labelArray2 objectAtIndex:i]];
        [Addresslbl setTextAlignment:NSTextAlignmentLeft];
        [AddvendorsView addSubview:Addresslbl];
        //// //NSLog(@"%f",Addresslbl.frame.origin.y);
        AddressField=[[UITextField alloc] init];
        //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
        AddressField.frame=CGRectMake(fieldwidth+GeneralinfoField.frame.size.width+10+Addresslbl.frame.size.width+5, h,fieldwidth-10, 40);
        [AddressField addTarget:self action:@selector(AddressFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
        AddressField.delegate=self;
        AddressField.tag=i+100;
        
        UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
        // // //NSLog(@"%f",AddressField.frame.origin.y);
        AddressField.leftView = paddingview;
        AddressField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
        AddressField.leftViewMode = UITextFieldViewModeAlways;
        //[AddressField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
        [AddressField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
        [AddressField setAutocorrectionType:UITextAutocorrectionTypeNo];
        
        
        [AddvendorsView addSubview:AddressField];
        
        h=h+60;
        paddingview=nil;
        
    }
    
    @autoreleasepool {
        SaveVendorsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        SaveVendorsBtn.frame=CGRectMake(fieldwidth+80, 800, 80, 30);
        [SaveVendorsBtn addTarget:self action:@selector(SaveVendorData) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [SaveVendorsBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[SaveVendorsBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [SaveVendorsBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        [AddvendorsView addSubview:SaveVendorsBtn];
        
        CancelVendorBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        CancelVendorBtn.frame=CGRectMake(fieldwidth+220, 800, 80, 30);
        [CancelVendorBtn addTarget:self action:@selector(CancelVendorData) forControlEvents:UIControlEventTouchUpInside];
        [CancelVendorBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[CancelVendorBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        [CancelVendorBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [AddvendorsView addSubview:CancelVendorBtn];
        
    }
    
    
    //edit vendor view
    
    NSString *querySQL = [NSString stringWithFormat: @"SELECT vendor_no,vendor_terms,vendor_min_order,vendor_commission_percent,vendor_company_name,vendor_flat_rent_rate,vendor_tax_id,vendor_billable_department,vendor_social_security_no,vendor_po_delivery_method,vendor_street_address,vendor_extended_address,vendor_city,vendor_state,vendor_zip_code,vendor_country,vendor_first_name,vendor_last_name,vendor_telephone_number,vendor_fax_number,vendor_email,vendor_website FROM vendor"];
    NSMutableArray *vendorsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:vendorsArray];
    
    NSMutableArray *rdarray=vendorsArray;
    
    //NSMutableArray *updateTableArray3=[[NSMutableArray alloc] init];
    
    [vendorPaginationObject setCompleteresultset:rdarray];
    
    [vendorPaginationObject  paginationinitializer:rdarray :6];
    
    [vendorPaginationObject paginationsegment].tintColor=[UIColor whiteColor];
    
    [[vendorPaginationObject paginationsegment] setFrame:CGRectMake(5, AddvendorBtn.frame.size.height+10,vendorsView.frame.size.width-10, 40)];
    
    [[vendorPaginationObject paginationsegment] addTarget:self action:@selector(segmentchanged3:) forControlEvents:UIControlEventValueChanged];
    
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [vendorPaginationObject paginationsegment].selectedSegmentIndex=selectedsegindex;
    [vendorPaginationObject activateResults:selectedsegindex];
    if (!EditVendorTable)
        EditVendorTable=[[UITableView alloc]init];
    [EditVendorTable  setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    EditVendorTable.frame=CGRectMake(5, AddvendorBtn.frame.size.height+50, vendorsView.frame.size.width-10, vendorsView.frame.size.height-20-AddvendorBtn.frame.size.height-40);
    EditVendorTable.delegate=self;
    EditVendorTable.dataSource=self;
    
}
-(void)AddvendorClicked
{
    EditvendorBtn.selected=NO;
    AddvendorBtn.selected=YES;
    
    [EditVendorTable removeFromSuperview];
    [[vendorPaginationObject paginationsegment] removeFromSuperview];
    [vendorsView addSubview:AddvendorsView];
    
    VendornumbersArray=nil;
    termsArray=nil;
    minimumorderArray=nil;
    commissionsArray=nil;
    companyNAmesArray=nil;
    flatrentsArray=nil;
    TaxidsArray=nil;
    billablesArray=nil;
    socialsArray=nil;
    podeliverysArray=nil;
    streetaddressArray=nil;
    exteddedArray=nil;
    citysArray=nil;
    statesArray=nil;
    ZipcodesArray=nil;
    countrysArray=nil;
    firstnamesArray=nil;
    lastnamesArray=nil;
    phnumbersArray=nil;
    faxesArray=nil;
    emailsArray=nil;
    websitesArray=nil;
}
-(void)EditVendorClicked
{
    NSString *querySQL = [NSString stringWithFormat: @"SELECT vendor_no,vendor_terms,vendor_min_order,vendor_commission_percent,vendor_company_name,vendor_flat_rent_rate,vendor_tax_id,vendor_billable_department,vendor_social_security_no,vendor_po_delivery_method,vendor_street_address,vendor_extended_address,vendor_city,vendor_state,vendor_zip_code,vendor_country,vendor_first_name,vendor_last_name,vendor_telephone_number,vendor_fax_number,vendor_email,vendor_website FROM vendor"];
    NSMutableArray *vendorsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:vendorsArray];
    
    NSMutableArray *rdarray=vendorsArray;
    
    // NSMutableArray *updateTableArray3=[[NSMutableArray alloc] init];
    
    [vendorPaginationObject setCompleteresultset:rdarray];
    
    [vendorPaginationObject  paginationinitializer:rdarray :6];
    
    [vendorPaginationObject paginationsegment].tintColor=[UIColor whiteColor];
    [[vendorPaginationObject paginationsegment] setFrame:CGRectMake(5, AddvendorBtn.frame.size.height+10,vendorsView.frame.size.width-10, 40)];
    
    [[vendorPaginationObject paginationsegment] addTarget:self action:@selector(segmentchanged3:) forControlEvents:UIControlEventValueChanged];
    
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [vendorPaginationObject paginationsegment].selectedSegmentIndex=selectedsegindex;
    [vendorPaginationObject activateResults:selectedsegindex];
    [EditVendorTable reloadData];
    AddvendorBtn.selected=NO;
    EditvendorBtn.selected=YES;
    [AddvendorsView removeFromSuperview];
    [vendorsView addSubview:[vendorPaginationObject paginationsegment]];
    [vendorsView addSubview:EditVendorTable];
    [self vendordataMethod];
    
}
-(void)ResultspersetBtnClicked
{
    if (DisplaySettable.hidden==1){
        
        DisplaySettable.hidden=NO;
        
    }else if (DisplaySettable.hidden==0){
        
        [DisplaySettable setHidden:YES];
        
    }
}
-(void) optionalInfoViewRemove
{
    
    NSArray *AddvendorsViewArray = OptionalInfoView.subviews;
    for (int i = 0; i<[AddvendorsViewArray count]; i++) {
        UIView *vi =[AddvendorsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *vendorsViewArray = OptionalInfoBackView.subviews;
    for (int i = 0; i<[vendorsViewArray count]; i++) {
        UIView *vi =[vendorsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [OptionalInfoView removeFromSuperview],[OptionalInfoBackView removeFromSuperview];
}
-(void) modifierlViewRemove
{
   
    NSArray *AddvendorsViewArray = modView.subviews;
    for (int i = 0; i<[AddvendorsViewArray count]; i++) {
        UIView *vi =[AddvendorsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *vendorsViewArray = modBackView.subviews;
    for (int i = 0; i<[vendorsViewArray count]; i++) {
        UIView *vi =[vendorsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [modView removeFromSuperview],[modBackView removeFromSuperview];
    
}
-(void) notesViewRemove
{
    NSArray *AddvendorsViewArray = NotesView.subviews;
    for (int i = 0; i<[AddvendorsViewArray count]; i++) {
        UIView *vi =[AddvendorsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *vendorsViewArray = NotesBackView.subviews;
    for (int i = 0; i<[vendorsViewArray count]; i++) {
        UIView *vi =[vendorsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [NotesView removeFromSuperview],[NotesBackView removeFromSuperview];
}
#pragma mark - product optional info views methods

-(void)infoButton1Clicked:(UIButton *)sender
{
    
    NSString *num=ItemNumberField.text;
    if ([num length]<=0)
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Please Enter Item Number" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
    }else{
    
    NSInteger selectedButton=sender.tag;
  
    if (selectedButton==100){
      
        //SkusArray=[[NSMutableArray alloc]init];
        if (!OptionalInfoBackView)
     OptionalInfoBackView=[[UIView alloc]init];
    if (isLandScope){
        OptionalInfoBackView.frame=CGRectMake(0, 0, 1024, 768);
    }else{
        
        OptionalInfoBackView.frame=CGRectMake(0, 0, 768, 1024);
    }
    [OptionalInfoBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:OptionalInfoBackView];
         if (!OptionalInfoView)
       OptionalInfoView=[[UIView alloc] init];
        if (isLandScope)
        {
             OptionalInfoView.frame=CGRectMake(50, 50, OptionalInfoBackView.frame.size.width-100, OptionalInfoBackView.frame.size.height-100);
        }else{
             OptionalInfoView.frame=CGRectMake(50, 150, OptionalInfoBackView.frame.size.width-100, OptionalInfoBackView.frame.size.height-400);
        }
        [OptionalInfoView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [OptionalInfoView.layer setBorderWidth:2.0];
        [OptionalInfoView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [OptionalInfoBackView addSubview:OptionalInfoView];
        
        CGFloat widthfield=(OptionalInfoView.frame.size.width)/4;
        CGFloat o=(widthfield/2);
          if (!OptionalinfoTextLbl)
        OptionalinfoTextLbl=[[UILabel alloc] init];
        OptionalinfoTextLbl.frame=CGRectMake(widthfield+60,10,widthfield+100, 40);
        [OptionalinfoTextLbl setFont:[UIFont systemFontOfSize:20.0f]];
        [OptionalinfoTextLbl setBackgroundColor:[UIColor clearColor]];
        [OptionalinfoTextLbl setTextColor:[UIColor whiteColor]];
        [OptionalinfoTextLbl setText:@"Optional Info Details"];
        [OptionalinfoTextLbl setTextAlignment:NSTextAlignmentLeft];
        [OptionalInfoView addSubview:OptionalinfoTextLbl];
        int w=60;
        NSArray *labelArray;
        if (!labelArray)
        labelArray=[[NSArray alloc] initWithObjects:@"Bonus Points",@"Barcodes",@"Location",@"UnitSize ",@"Unit Type",nil];
        for (int i=0; i<5; i++)
        {
            
            Optionalinfolbl=[[UILabel alloc] init];
            Optionalinfolbl.frame=CGRectMake(o-80, w,widthfield+10, 40);
            Optionalinfolbl.tag=i+100;
            [Optionalinfolbl setFont:[UIFont systemFontOfSize:20.0f]];
            [Optionalinfolbl setBackgroundColor:[UIColor clearColor]];
            [Optionalinfolbl setTextColor:[UIColor whiteColor]];
           
            [Optionalinfolbl setText:[labelArray objectAtIndex:i]];
            [Optionalinfolbl setTextAlignment:NSTextAlignmentLeft];
            [OptionalInfoView addSubview:Optionalinfolbl];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            OptionalinfoFields=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            if (isLandScope) {
                OptionalinfoFields.frame=CGRectMake(o+Optionalinfolbl.frame.size.width-150, w,widthfield-60, 40);
            }
            else
            {
                OptionalinfoFields.frame=CGRectMake(o+Optionalinfolbl.frame.size.width-130, w,widthfield-60, 40);
                
            }
            
            OptionalinfoFields.delegate=self;
            OptionalinfoFields.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            if (OptionalinfoFields.tag==100)
            {
                OptionalinfoFields.text=OPBonusPoints;
            }
            if (OptionalinfoFields.tag==101)
            {
                OptionalinfoFields.text=OPBarcodes;
            }
            if (OptionalinfoFields.tag==102)
            {
                OptionalinfoFields.text=OPlocation;
            }
            if (OptionalinfoFields.tag==103)
            {
                OptionalinfoFields.text=OPunitsize;
            }
            if (OptionalinfoFields.tag==104)
            {
                OptionalinfoFields.text=OPunittype;
            }
           
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            OptionalinfoFields.leftView = paddingview;
            OptionalinfoFields.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            OptionalinfoFields.leftViewMode = UITextFieldViewModeAlways;
            //[OptionalinfoFields setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
           [OptionalinfoFields setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
            //[ResultspersetBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
            [OptionalinfoFields addTarget:self action:@selector(OptionalinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
            [OptionalinfoFields setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [OptionalInfoView addSubview:OptionalinfoFields];
            
            w=w+60;
            paddingview=nil;
            
        }
          if (!OptCommissonlbl)
        OptCommissonlbl=[[UILabel alloc] init];
        OptCommissonlbl.frame=CGRectMake(o-80,360,widthfield+10, 40);
        [OptCommissonlbl setFont:[UIFont systemFontOfSize:20.0f]];
        [OptCommissonlbl setBackgroundColor:[UIColor clearColor]];
        [OptCommissonlbl setTextColor:[UIColor whiteColor]];
        [OptCommissonlbl setText:@"Commission"];
        [OptCommissonlbl setTextAlignment:NSTextAlignmentLeft];
        [OptionalInfoView addSubview:OptCommissonlbl];
        if (!optCommissionBtn)
        optCommissionBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        optCommissionBtn.frame=CGRectMake(widthfield-30, 360,widthfield-60, 40);
        [optCommissionBtn addTarget:self action:@selector(CommisionBtnClicked) forControlEvents:UIControlEventTouchUpInside];
        [optCommissionBtn setTitle:OPCommission forState:UIControlStateNormal];
        [optCommissionBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        //[optCommissionBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
        [optCommissionBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
        
        [OptionalInfoView addSubview:optCommissionBtn];
        if (!CommissionsTable)
        CommissionsTable = [[UITableView alloc] initWithFrame:CGRectMake(widthfield-30, 400,widthfield-60, 100) style:UITableViewStylePlain];
        CommissionsTable.backgroundColor=[UIColor whiteColor];
        CommissionsTable.delegate = self;
        CommissionsTable.dataSource = self;
        CommissionsTable.hidden=YES;
        CommissionsTable.scrollEnabled = YES;
        [CommissionsTable.layer setBorderWidth: 1.0];
        [CommissionsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [OptionalInfoView addSubview:CommissionsTable];
        
         if (!Alternatelbl)
        Alternatelbl=[[UILabel alloc] init];
        Alternatelbl.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width-10,60,widthfield+10, 40);
        [Alternatelbl setFont:[UIFont systemFontOfSize:20.0f]];
        [Alternatelbl setBackgroundColor:[UIColor clearColor]];
        [Alternatelbl setTextColor:[UIColor whiteColor]];
        [Alternatelbl setText:@"Alternate SKUs"];
        [Alternatelbl setTextAlignment:NSTextAlignmentLeft];
        [OptionalInfoView addSubview:Alternatelbl];
         if (!AlternateTable)
        AlternateTable = [[UITableView alloc] initWithFrame:CGRectMake(widthfield+optCommissionBtn.frame.size.width-10,95,widthfield+80, 100) style:UITableViewStylePlain];
        AlternateTable.backgroundColor=[UIColor whiteColor];
        AlternateTable.delegate = self;
        AlternateTable.dataSource = self;
        AlternateTable.scrollEnabled = YES;
        [AlternateTable.layer setBorderWidth: 1.0];
        [AlternateTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [OptionalInfoView addSubview:AlternateTable];
        
         if (!AddskuBtn)
        AddskuBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [AddskuBtn setTitle:@"Add Alternate Sku's" forState:UIControlStateNormal];
        //[AddskuBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
        [AddskuBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]] forState:UIControlStateNormal];
        AddskuBtn.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width+Alternatelbl.frame.size.width+80,100,widthfield-50, 80);
        [AddskuBtn addTarget:self action:@selector(AddskusClicked) forControlEvents:UIControlEventTouchUpInside];
        AddskuBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
        AddskuBtn.titleLabel.numberOfLines = 2;
        AddskuBtn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
        [AddskuBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        [OptionalInfoView addSubview:AddskuBtn];
        
      /*  tagAlongitemlbl=[[UILabel alloc] init];
        tagAlongitemlbl.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width+Alternatelbl.frame.size.width+10,60,widthfield+10, 40);
        [tagAlongitemlbl setFont:[UIFont systemFontOfSize:20.0f]];
        [tagAlongitemlbl setBackgroundColor:[UIColor clearColor]];
        [tagAlongitemlbl setTextColor:[UIColor whiteColor]];
        [tagAlongitemlbl setText:@"Tag Along Items"];
        [tagAlongitemlbl setTextAlignment:NSTextAlignmentLeft];
        [OptionalInfoView addSubview:tagAlongitemlbl];
        TagAlongitemtable = [[UITableView alloc] initWithFrame:CGRectMake(widthfield+optCommissionBtn.frame.size.width+Alternatelbl.frame.size.width+10,95,widthfield+10, 100) style:UITableViewStylePlain];
        TagAlongitemtable.backgroundColor=[UIColor whiteColor];
        TagAlongitemtable.delegate = self;
        TagAlongitemtable.dataSource = self;
        TagAlongitemtable.scrollEnabled = YES;
        [TagAlongitemtable.layer setBorderWidth: 2.0];
        [TagAlongitemtable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [OptionalInfoView addSubview:TagAlongitemtable];*/
        
        
        int z=210;
        for (int i=0; i<6; i++)
        {
            ItemBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            ItemBtn.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width-10,z,30, 30);
            ItemBtn.tag=i+100;
            [ItemBtn addTarget:self action:@selector(ItemBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
            [ItemBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            //[ItemBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
            [ItemBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
           // [ItemBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
            [ItemBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
            [OptionalInfoView addSubview:ItemBtn];
            Itemlbl=[[UILabel alloc] init];
            if (isLandScope)
            {
                 Itemlbl.frame=CGRectMake(widthfield+ItemBtn.frame.size.width+170, z-5,widthfield+10, 40);
            }
            else
            {
            Itemlbl.frame=CGRectMake(widthfield+ItemBtn.frame.size.width+120, z-5,widthfield+10, 40);
            }
            if (ItemBtn.tag==100)
            {
                if ([modifierItem isEqualToString:@"yes"])
                {
                    ItemBtn.selected=YES;
                     modifierItem=@"yes";
                }
                else{
                    ItemBtn.selected=NO;
                    modifierItem=@"no";
                    
                }
               
            }
            if (ItemBtn.tag==101)
            {
                if ([CountthisItem isEqualToString:@"yes"])
                {
                    ItemBtn.selected=YES;
                    CountthisItem=@"yes";
                }
                else{
                    ItemBtn.selected=NO;
                    CountthisItem=@"no";
                    
                }
              
            }
            if (ItemBtn.tag==102)
            {
                if ([allowbuyback isEqualToString:@"yes"])
                {
                    ItemBtn.selected=YES;
                    allowbuyback=@"yes";
                }
                else{
                    ItemBtn.selected=NO;
                    allowbuyback=@"no";
                    
                }
                
               
            }
            if (ItemBtn.tag==103)
            {
                if ([printonreceipt isEqualToString:@"yes"])
                {
                    ItemBtn.selected=YES;
                    printonreceipt=@"yes";
                }
                else{
                    ItemBtn.selected=NO;
                    printonreceipt=@"no";
                    
                }
             
            }
            if (ItemBtn.tag==104)
            {
                if ([foodstampable isEqualToString:@"YES"])
                {
                    ItemBtn.selected=YES;
                    foodstampable=@"yes";
                }
                else{
                    ItemBtn.selected=NO;
                    foodstampable=@"no";
                    
                }
              
            }
            if (ItemBtn.tag==105)
            {
                if ([Promptprice isEqualToString:@"yes"])
                {
                    ItemBtn.selected=YES;
                    Promptprice=@"yes";
                }
                else{
                    ItemBtn.selected=NO;
                    Promptprice=@"no";
                    
                }
                
            }
            Itemlbl.tag=i+100;
            [Itemlbl setFont:[UIFont systemFontOfSize:20.0f]];
            [Itemlbl setBackgroundColor:[UIColor clearColor]];
            [Itemlbl setTextColor:[UIColor whiteColor]];
            NSArray *labelArray=[[NSArray alloc] initWithObjects:@"Modifier Item",@"Count This Item",@"Prompt Quantity",@"Print On Receipt",@"Foodstampable",@"Prompt price",nil];
            [Itemlbl setText:[labelArray objectAtIndex:i]];
            [Itemlbl setTextAlignment:NSTextAlignmentLeft];
            [OptionalInfoView addSubview:Itemlbl];
            z=z+40;
            
        }
        
        @autoreleasepool {
            OptionalinfoSaveBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            OptionalinfoSaveBtn.frame=CGRectMake(widthfield+120,520,80,30);
            [OptionalinfoSaveBtn addTarget:self action:@selector(SaveOptionalInfo) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [OptionalinfoSaveBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[OptionalinfoSaveBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [OptionalinfoSaveBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            [OptionalInfoView addSubview:OptionalinfoSaveBtn];
            
            OptionalinfoCancelBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            OptionalinfoCancelBtn.frame=CGRectMake(widthfield+220,520,80,30);
            [OptionalinfoCancelBtn addTarget:self action:@selector(OptionalInfoCancelclicked) forControlEvents:UIControlEventTouchUpInside];
            [OptionalinfoCancelBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[OptionalinfoCancelBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            [OptionalinfoCancelBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [OptionalInfoView addSubview:OptionalinfoCancelBtn];
        }
       
        
    }else if (selectedButton==101){
        if (!NotesBackView)
        NotesBackView=[[UIView alloc]init];
        if (isLandScope) {
            NotesBackView.frame=CGRectMake(0, 0, 1024, 768);
        }else{
            
            NotesBackView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [NotesBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:NotesBackView];
        if (!NotesView)
        NotesView=[[UIView alloc] init];
        if (isLandScope)
        {
             NotesView.frame=CGRectMake(50, 50, NotesBackView.frame.size.width-100, NotesBackView.frame.size.height-100);
        }else{
             NotesView.frame=CGRectMake(50, 150, NotesBackView.frame.size.width-100, NotesBackView.frame.size.height-400);
        }
        [NotesView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [NotesView.layer setBorderWidth:2.0];
        [NotesView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [NotesBackView addSubview:NotesView];
        
         CGFloat widthfield3=(NotesView.frame.size.width)/4;
        if (!Notestextlbl)
        Notestextlbl=[[UILabel alloc] init];
        Notestextlbl.frame=CGRectMake(10,10,NotesView.frame.size.width-50,140);
        [Notestextlbl setFont:[UIFont systemFontOfSize:20.0f]];
        [Notestextlbl setBackgroundColor:[UIColor clearColor]];
        [Notestextlbl setTextColor:[UIColor whiteColor]];
        [Notestextlbl setText:@"You can enter notes to describe your item.This can be used to describe instructions to care for a plant,ingredients inside a meal,or other useful information."];
        Notestextlbl.lineBreakMode = NSLineBreakByWordWrapping;
        Notestextlbl.numberOfLines = 3;
        [Notestextlbl setTextAlignment:NSTextAlignmentLeft];
        [NotesView addSubview:Notestextlbl];
         if (!NotesTextView)
        NotesTextView=[[UITextView alloc] init];
        NotesTextView.frame=CGRectMake(10, 115,NotesView.frame.size.width-20,400);
        NotesTextView.delegate=self;
        NotesTextView.text=Productnotes;
        NotesTextView.font=[UIFont systemFontOfSize:14.0f];
        [NotesTextView setAutocorrectionType:UITextAutocorrectionTypeNo];
        NotesTextView.layer.cornerRadius=8;
        [NotesView addSubview:NotesTextView];
        @autoreleasepool {
            SaveNotesBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SaveNotesBtn.frame=CGRectMake(widthfield3+120,540,80,30);
            [SaveNotesBtn addTarget:self action:@selector(SaveProductNotes) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SaveNotesBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[SaveNotesBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [SaveNotesBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            [NotesView addSubview:SaveNotesBtn];
            
            CancelNotesBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelNotesBtn.frame=CGRectMake(widthfield3+220,540,80,30);
            [CancelNotesBtn addTarget:self action:@selector(NotesCancelclicked) forControlEvents:UIControlEventTouchUpInside];
            [CancelNotesBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            // [CancelNotesBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            [CancelNotesBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [NotesView addSubview:CancelNotesBtn];
        }
     
        
    }else if (selectedButton==102){
          
           // UIButton *ModifieritemsDropdownBtn,*SavemodBtn,*CancelModBtn;
            //UITableView *ItemsListTable,*modifierItemsTable;
             if (!modBackView)
            modBackView=[[UIView alloc]init];
            if (isLandScope){
                modBackView.frame=CGRectMake(0, 0, 1024, 768);
            }else{
                
                modBackView.frame=CGRectMake(0, 0, 768, 1024);
            }
            [modBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
            [self.view addSubview:modBackView];
            
            modView=[[UIView alloc] init];
            if (isLandScope){
                modView.frame=CGRectMake(50, 50, modBackView.frame.size.width-100, modBackView.frame.size.height-100);
            }else{
                modView.frame=CGRectMake(50, 150, modBackView.frame.size.width-100, modBackView.frame.size.height-400);
            }
            [modView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
            [modView.layer setBorderWidth:2.0];
            [modView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
            [modBackView addSubview:modView];
            
            CGFloat Modwidthfield=(modView.frame.size.width)/2;
              if (!modTextlbl)
            modTextlbl=[[UILabel alloc] init];
            modTextlbl.frame=CGRectMake(Modwidthfield-100,5,Modwidthfield+200, 40);
            [modTextlbl setFont:[UIFont systemFontOfSize:22.0f]];
            [modTextlbl setBackgroundColor:[UIColor clearColor]];
            [modTextlbl setTextColor:[UIColor whiteColor]];
            [modTextlbl setText:@"Modifier List"];
            [modTextlbl setTextAlignment:NSTextAlignmentLeft];
            [modView addSubview:modTextlbl];
        
            ItemNumbersArray=[[NSMutableArray alloc]init];
            itemsListArray=[[NSMutableArray alloc]init];
            
            ItemnameArray=[[NSMutableArray alloc]init];
            NamesArray=[[NSMutableArray alloc]init];
            ModifierItemNosArray=[[NSMutableArray alloc]init];
            modifierItemsArray=[[NSMutableArray alloc]init];
            modifierNamesArray=[[NSMutableArray alloc]init];
             NSString *querySQL = [NSString stringWithFormat:@"SELECT inventary_modifier_item,inventory_item_no FROM optional_info_table"];
        
            NSMutableArray *optinfoArray=[[NSMutableArray alloc]init];
            [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:optinfoArray];
            
           
             NSString *prodquerySQL = [NSString stringWithFormat: @"SELECT inventary_item_name FROM inventorytable"];
            NSMutableArray *productArray=[[NSMutableArray alloc]init];
            [[DataBaseManager dataBaseManager]execute:prodquerySQL resultsArray:productArray];
            if ([optinfoArray count]>0)
            {
                for (NSDictionary *myDict in optinfoArray)
                {
                    
                    [modifierItemsArray addObject:[myDict objectForKey:@"inventary_modifier_item"]];
                    
                    [ItemNumbersArray addObject:[myDict objectForKey:@"inventory_item_no"]];
                    
                    
                }
                for (NSDictionary *myDict in productArray)
                {
                    [ItemnameArray addObject:[myDict objectForKey:@"inventary_item_name"]];
                }
                
                if ([modifierItemsArray count]>0) {
                    for (int i=0; i<[modifierItemsArray count]; i++)
                    {
                        NSString *mystr=[modifierItemsArray objectAtIndex:i];
                        if ([mystr isEqualToString:@"yes"])
                        {
                            NSString *item=[ItemNumbersArray objectAtIndex:i];
                            NSString *name=[ItemnameArray objectAtIndex:i];
                            
                            [NamesArray addObject:name];
                            
                            [itemsListArray addObject:item];
                        }
                    }
                    
                }
                
            }

       
        
            // //NSLog(@"%@",itemsListArray);
            ModifieritemsDropdownBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            ModifieritemsDropdownBtn.frame=CGRectMake(20, 50,Modwidthfield-150, 40);
            [ModifieritemsDropdownBtn addTarget:self action:@selector(ModifierItemClicked) forControlEvents:UIControlEventTouchUpInside];
           
            [ModifieritemsDropdownBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            //[ModifieritemsDropdownBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
            [ModifieritemsDropdownBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
            [modView addSubview:ModifieritemsDropdownBtn];
           if (!ItemsListTable)
            ItemsListTable = [[UITableView alloc] initWithFrame:CGRectMake(20, 90,Modwidthfield-150, 200) style:UITableViewStylePlain];
            ItemsListTable.backgroundColor=[UIColor whiteColor];
            ItemsListTable.delegate = self;
            ItemsListTable.dataSource = self;
            ItemsListTable.hidden=YES;
            ItemsListTable.scrollEnabled = YES;
            [ItemsListTable.layer setBorderWidth: 1.0];
            [ItemsListTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
            [modView addSubview:ItemsListTable];
        [ItemsListTable  reloadData];
             if (!modifierItemsTable)
            modifierItemsTable = [[UITableView alloc] initWithFrame:CGRectMake(20+ModifieritemsDropdownBtn.frame.size.width+10, 40,modView.frame.size.width-(20+ModifieritemsDropdownBtn.frame.size.width+20), 400) style:UITableViewStylePlain];
            modifierItemsTable.backgroundColor=[UIColor whiteColor];
            modifierItemsTable.delegate = self;
            modifierItemsTable.dataSource = self;
           // modifierItemsTable.hidden=YES;
            modifierItemsTable.scrollEnabled = YES;
            [modifierItemsTable.layer setBorderWidth: 1.0];
            [modifierItemsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
            [modView addSubview:modifierItemsTable];
             [modifierItemsTable  reloadData];
        @autoreleasepool {
            SavemodBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SavemodBtn.frame=CGRectMake(Modwidthfield-100,460,80,30);
            [SavemodBtn addTarget:self action:@selector(SaveModifierData) forControlEvents:UIControlEventTouchUpInside];
            [SavemodBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[SavemodBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [SavemodBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            [modView addSubview:SavemodBtn];
            
            CancelModBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelModBtn.frame=CGRectMake(Modwidthfield+30,460,80,30);
            [CancelModBtn addTarget:self action:@selector(ModifierCancelClicked) forControlEvents:UIControlEventTouchUpInside];
            [CancelModBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[CancelModBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            [CancelModBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [modView addSubview:CancelModBtn];
        }
        
            
        }
        
        /*if (selectedButton==101)
         {
         PendingOrderBackView=[[UIView alloc]init];
         if (isLandScope) {
         PendingOrderBackView.frame=CGRectMake(0, 0, 1024, 768);
         }
         
         else{
         
         PendingOrderBackView.frame=CGRectMake(0, 0, 768, 1024);
         }
         [PendingOrderBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
         [self.view addSubview:PendingOrderBackView];
         
         PendingOrderView=[[UIView alloc] init];
         PendingOrderView.frame=CGRectMake(50, 50, PendingOrderBackView.frame.size.width-100, PendingOrderBackView.frame.size.height-100);
         
         [PendingOrderView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
         
         [PendingOrderBackView addSubview:PendingOrderView];
         
         
         CGFloat widthfield2=(PendingOrderView.frame.size.width)/4;
         CGFloat pen=(widthfield2/2);
         PendingOrderTextlbl=[[UILabel alloc] init];
         PendingOrderTextlbl.frame=CGRectMake(widthfield2+60,10,widthfield2+200, 40);
         [PendingOrderTextlbl setFont:[UIFont systemFontOfSize:22.0f]];
         [PendingOrderTextlbl setBackgroundColor:[UIColor clearColor]];
         [PendingOrderTextlbl setTextColor:[UIColor whiteColor]];
         [PendingOrderTextlbl setText:@"Pending Order Details"];
         [PendingOrderTextlbl setTextAlignment:NSTextAlignmentLeft];
         [PendingOrderView addSubview:PendingOrderTextlbl];
         OpenRadioBtn = [[UIButton alloc] init];
         OpenRadioBtn.frame=CGRectMake(pen-60, 60, 25, 25);
         [OpenRadioBtn setTag:0];
         [OpenRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
         [OpenRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
         
         [OpenRadioBtn addTarget:self action:@selector(OpenRadioBtnClciked) forControlEvents:UIControlEventTouchUpInside];
         [PendingOrderView addSubview:OpenRadioBtn];
         openlbl=[[UILabel alloc] init];
         openlbl.frame=CGRectMake(pen-60+OpenRadioBtn.frame.size.width+5,55,widthfield2,40);
         [openlbl setFont:[UIFont systemFontOfSize:20.0f]];
         [openlbl setBackgroundColor:[UIColor clearColor]];
         [openlbl setTextColor:[UIColor whiteColor]];
         [openlbl setText:@"Open"];
         OpenRadioBtn.selected=YES;
         [openlbl setTextAlignment:NSTextAlignmentLeft];
         [PendingOrderView addSubview:openlbl];
         
         
         CompleteRadioBtn = [[UIButton alloc] init];
         CompleteRadioBtn.frame=CGRectMake(pen-60+openlbl.frame.size.width, 60, 25, 25);
         [CompleteRadioBtn setTag:1];
         [CompleteRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
         [CompleteRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
         [CompleteRadioBtn addTarget:self action:@selector(CompleteRadioBtnClicked) forControlEvents:UIControlEventTouchUpInside];
         [PendingOrderView addSubview:CompleteRadioBtn];
         
         completelbl=[[UILabel alloc] init];
         completelbl.frame=CGRectMake(pen-35+openlbl.frame.size.width,55,widthfield2,40);
         [completelbl setFont:[UIFont systemFontOfSize:20.0f]];
         [completelbl setBackgroundColor:[UIColor clearColor]];
         [completelbl setTextColor:[UIColor whiteColor]];
         [completelbl setText:@"Complete"];
         [completelbl setTextAlignment:NSTextAlignmentLeft];
         [PendingOrderView addSubview:completelbl];
         
         CancelRadioBtn = [[UIButton alloc] init];
         CancelRadioBtn.frame=CGRectMake(pen-60+openlbl.frame.size.width+completelbl.frame.size.width+20, 60, 25, 25);
         [CancelRadioBtn setTag:2];
         [CancelRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
         [CancelRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
         [CancelRadioBtn addTarget:self action:@selector(CancelRadioBtnClicked) forControlEvents:UIControlEventTouchUpInside];
         [PendingOrderView addSubview:CancelRadioBtn];
         
         cancellbl=[[UILabel alloc] init];
         cancellbl.frame=CGRectMake(pen-35+openlbl.frame.size.width+completelbl.frame.size.width+20,55,widthfield2,40);
         [cancellbl setFont:[UIFont systemFontOfSize:20.0f]];
         [cancellbl setBackgroundColor:[UIColor clearColor]];
         [cancellbl setTextColor:[UIColor whiteColor]];
         [cancellbl setText:@"Cancel"];
         [cancellbl setTextAlignment:NSTextAlignmentLeft];
         [PendingOrderView addSubview:cancellbl];
         
         PendingOrdersTable = [[UITableView alloc] initWithFrame:CGRectMake(pen-60,95,widthfield2+450, 400) style:UITableViewStylePlain];
         PendingOrdersTable.backgroundColor=[UIColor whiteColor];
         PendingOrdersTable.delegate = self;
         PendingOrdersTable.dataSource = self;
         PendingOrdersTable.scrollEnabled = YES;
         [PendingOrdersTable.layer setBorderWidth: 2.0];
         [PendingOrdersTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
         [PendingOrderView addSubview:PendingOrdersTable];
         
         //        CompletethisorderBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
         //
         //        [CompletethisorderBtn setTitle:@"Complete This Order" forState:UIControlStateNormal];
         //        [CompletethisorderBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
         //        CompletethisorderBtn.frame=CGRectMake(PendingOrdersTable.frame.size.width+60,170,100, 100);
         //        [CompletethisorderBtn addTarget:self action:@selector(infoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
         //          CompletethisorderBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
         //        CompletethisorderBtn.titleLabel.numberOfLines = 2;
         //        CompletethisorderBtn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
         //        [CompletethisorderBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
         //
         //        [PendingOrderView addSubview:CompletethisorderBtn];
         //        cancelthisOrderBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
         //
         //        [cancelthisOrderBtn setTitle:@"Cancel This Order" forState:UIControlStateNormal];
         //        [cancelthisOrderBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
         //        cancelthisOrderBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
         //        cancelthisOrderBtn.frame=CGRectMake(PendingOrdersTable.frame.size.width+60,340,100, 100);
         //        [cancelthisOrderBtn addTarget:self action:@selector(infoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
         //        cancelthisOrderBtn.titleLabel.numberOfLines = 2;
         //        cancelthisOrderBtn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
         //        [cancelthisOrderBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
         //
         //        [PendingOrderView addSubview:cancelthisOrderBtn];
         
         SavePendingorderBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
         
         SavePendingorderBtn.frame=CGRectMake(widthfield2+40,520,80,40);
         [SavePendingorderBtn addTarget:self action:@selector(SaveProductData) forControlEvents:UIControlEventTouchUpInside];
         
         //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
         [SavePendingorderBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
         [SavePendingorderBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
         [PendingOrderView addSubview:SavePendingorderBtn];
         
         CancelPendingorderBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
         
         CancelPendingorderBtn.frame=CGRectMake(widthfield2+240,520,80,40);
         [CancelPendingorderBtn addTarget:self action:@selector(PendingInfoCancelclicked) forControlEvents:UIControlEventTouchUpInside];
         [CancelPendingorderBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
         [CancelPendingorderBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
         // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
         [PendingOrderView addSubview:CancelPendingorderBtn];
         
         }*/
  /*  if (selectedButton==102)
    {
        ModifierBackView=[[UIView alloc]init];
        if (isLandScope) {
            ModifierBackView.frame=CGRectMake(0, 0, 1024, 768);
        }
        
        else{
            
            ModifierBackView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [ModifierBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:ModifierBackView];
        
        ModifierView=[[UIView alloc] init];
        ModifierView.frame=CGRectMake(50, 50, ModifierBackView.frame.size.width-100, ModifierBackView.frame.size.height-100);
        
        [ModifierView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        
        [ModifierBackView addSubview:ModifierView];
        
        CGFloat widthfield4=(ModifierView.frame.size.width)/4;
        CGFloat mod=(widthfield4/2)+100;
        ModifierTextlbl=[[UILabel alloc] init];
        ModifierTextlbl.frame=CGRectMake(widthfield4+60,10,widthfield4+200, 40);
        [ModifierTextlbl setFont:[UIFont systemFontOfSize:22.0f]];
        [ModifierTextlbl setBackgroundColor:[UIColor clearColor]];
        [ModifierTextlbl setTextColor:[UIColor whiteColor]];
        [ModifierTextlbl setText:@"Modifier List"];
        [ModifierTextlbl setTextAlignment:NSTextAlignmentLeft];
        [ModifierView addSubview:ModifierTextlbl];
        
        GroupRadioBtn = [[UIButton alloc] init];
        GroupRadioBtn.frame=CGRectMake(mod, 60, 25, 25);
        [GroupRadioBtn setTag:1];
        [GroupRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
        [GroupRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
        [GroupRadioBtn addTarget:self action:@selector(GroupRadioBtnClicked) forControlEvents:UIControlEventTouchUpInside];
        GroupRadioBtn.selected=YES;
        [ModifierView addSubview:GroupRadioBtn];
        
        Grouplbl=[[UILabel alloc] init];
        Grouplbl.frame=CGRectMake(mod+GroupRadioBtn.frame.size.width+5,55,100,40);
        [Grouplbl setFont:[UIFont systemFontOfSize:20.0f]];
        [Grouplbl setBackgroundColor:[UIColor clearColor]];
        [Grouplbl setTextColor:[UIColor whiteColor]];
        [Grouplbl setText:@"Group"];
        [Grouplbl setTextAlignment:NSTextAlignmentLeft];
        [ModifierView addSubview:Grouplbl];
        
        IndividualRadioBtn = [[UIButton alloc] init];
        IndividualRadioBtn.frame=CGRectMake(mod+GroupRadioBtn.frame.size.width+Grouplbl.frame.size.width+20, 60, 25, 25);
        [IndividualRadioBtn setTag:1];
        [IndividualRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
        [IndividualRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
        [IndividualRadioBtn addTarget:self action:@selector(IndividualRadioBtnClicked) forControlEvents:UIControlEventTouchUpInside];
        [ModifierView addSubview:IndividualRadioBtn];
        individuallbl=[[UILabel alloc] init];
        individuallbl.frame=CGRectMake(mod+GroupRadioBtn.frame.size.width+Grouplbl.frame.size.width+50,55,200,40);
        [individuallbl setFont:[UIFont systemFontOfSize:20.0f]];
        [individuallbl setBackgroundColor:[UIColor clearColor]];
        [individuallbl setTextColor:[UIColor whiteColor]];
        [individuallbl setText:@"Individual Items"];
        [individuallbl setTextAlignment:NSTextAlignmentLeft];
        [ModifierView addSubview:individuallbl];
        
        ModifierGroupView=[[UIView alloc] init];
        ModifierGroupView.frame=CGRectMake(0,100 , ModifierView.frame.size.width, ModifierView.frame.size.height-200);
        
        [ModifierGroupView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        
        [ModifierView addSubview:ModifierGroupView];
        
        CGFloat widthfield5=(ModifierGroupView.frame.size.width)/4;
        CGFloat group=(widthfield5/2)+100;
        if (isLandScope)
        {
             ModifierGroupTable = [[UITableView alloc] initWithFrame:CGRectMake(group,0,widthfield5+450, 300) style:UITableViewStylePlain];
        }
        else
        {
        ModifierGroupTable = [[UITableView alloc] initWithFrame:CGRectMake(group,0,widthfield5+300, 300) style:UITableViewStylePlain];
        }
        ModifierGroupTable.backgroundColor=[UIColor whiteColor];
        ModifierGroupTable.delegate = self;
        ModifierGroupTable.dataSource = self;
        ModifierGroupTable.scrollEnabled = YES;
        [ModifierGroupTable.layer setBorderWidth: 2.0];
        [ModifierGroupTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [ModifierGroupView addSubview:ModifierGroupTable];
        
        AddModifierGroupBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [AddModifierGroupBtn setTitle:@"Add Modifier Group" forState:UIControlStateNormal];
        [AddModifierGroupBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
    
        AddModifierGroupBtn.frame=CGRectMake(40,20,widthfield5-80,80);
         [AddModifierGroupBtn addTarget:self action:@selector(infoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
             AddModifierGroupBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
              AddModifierGroupBtn.titleLabel.numberOfLines = 2;
             AddModifierGroupBtn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
            [AddModifierGroupBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        [ModifierGroupView addSubview:AddModifierGroupBtn];
        
        ModifierDeslbl=[[UILabel alloc] init];
        ModifierDeslbl.frame=CGRectMake(40,100,widthfield5,40);
        [ModifierDeslbl setFont:[UIFont systemFontOfSize:20.0f]];
        [ModifierDeslbl setBackgroundColor:[UIColor clearColor]];
        [ModifierDeslbl setTextColor:[UIColor whiteColor]];
        [ModifierDeslbl setText:@"Description"];
        [ModifierDeslbl setTextAlignment:NSTextAlignmentLeft];
        [ModifierGroupView addSubview:ModifierDeslbl];
        
        ModifierDesField=[[UITextField alloc] init];
        //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
        
      ModifierDesField.frame=CGRectMake(20, 140,widthfield5-40, 40);
        ModifierDesField.delegate=self;
        UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
        // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
        ModifierDesField.leftView = paddingview;
        ModifierDesField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
        ModifierDesField.leftViewMode = UITextFieldViewModeAlways;
        [ModifierDesField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
        
        [ModifierDesField addTarget:self action:@selector(GeneralinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
        [ModifierDesField setAutocorrectionType:UITextAutocorrectionTypeNo];
        
        //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
        
        [ModifierGroupView addSubview:ModifierDesField];
        
        promptlbl=[[UILabel alloc] init];
        promptlbl.frame=CGRectMake(40,180,widthfield5,40);
        [promptlbl setFont:[UIFont systemFontOfSize:20.0f]];
        [promptlbl setBackgroundColor:[UIColor clearColor]];
        [promptlbl setTextColor:[UIColor whiteColor]];
        [promptlbl setText:@"Prompt"];
        [promptlbl setTextAlignment:NSTextAlignmentLeft];
        [ModifierGroupView addSubview:promptlbl];
        
        PromptField=[[UITextField alloc] init];
        //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
        
        PromptField.frame=CGRectMake(20, 220,widthfield5-40, 40);
        PromptField.delegate=self;
        UIView *paddingview2=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
        // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
        PromptField.leftView = paddingview2;
        PromptField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
        PromptField.leftViewMode = UITextFieldViewModeAlways;
        [PromptField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
        
        [PromptField addTarget:self action:@selector(GeneralinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
        [PromptField setAutocorrectionType:UITextAutocorrectionTypeNo];
        
        //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
        
        [ModifierGroupView addSubview:PromptField];
        
        Toselectlbl=[[UILabel alloc] init];
        Toselectlbl.frame=CGRectMake(20,290,widthfield5, 40);

        [Toselectlbl setFont:[UIFont systemFontOfSize:20.0f]];
        [Toselectlbl setBackgroundColor:[UIColor clearColor]];
        [Toselectlbl setTextColor:[UIColor whiteColor]];
        [Toselectlbl setText:@"#To Select"];
        [Toselectlbl setTextAlignment:NSTextAlignmentLeft];
        [ModifierGroupView addSubview:Toselectlbl];
        
        ToSelectBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        ToSelectBtn.frame=CGRectMake(20,320,widthfield5, 40);
        [ToSelectBtn addTarget:self action:@selector(AddpricingClicked) forControlEvents:UIControlEventTouchUpInside];
        [ToSelectBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [ToSelectBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
        [ModifierGroupView addSubview:ToSelectBtn];
    ToSelectTable = [[UITableView alloc] initWithFrame:CGRectMake(20,360,widthfield5, 100) style:UITableViewStylePlain];
    ToSelectTable.backgroundColor=[UIColor whiteColor];
    ToSelectTable.delegate = self;
    ToSelectTable.dataSource = self;
        ToSelectTable.hidden=YES;
    ToSelectTable.scrollEnabled = YES;
    [ToSelectTable.layer setBorderWidth: 2.0];
    [ToSelectTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [ModifierGroupView addSubview:ToSelectTable];
    
        ChargeforModifierBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        ChargeforModifierBtn.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10,325,30, 30);
       
        [ChargeforModifierBtn addTarget:self action:@selector(BarBtnClicked) forControlEvents:UIControlEventTouchUpInside];
        [ChargeforModifierBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [ChargeforModifierBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
        [ChargeforModifierBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
        [ModifierGroupView addSubview:ChargeforModifierBtn];
        
        
        chargeforModifierlbl=[[UILabel alloc] init];
        chargeforModifierlbl.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10+ChargeforModifierBtn.frame.size.width+10,323,widthfield5+50, 40);
        
        [chargeforModifierlbl setFont:[UIFont systemFontOfSize:20.0f]];
        [chargeforModifierlbl setBackgroundColor:[UIColor clearColor]];
        [chargeforModifierlbl setTextColor:[UIColor whiteColor]];
        [chargeforModifierlbl setText:@"Change for modifiers"];
        [chargeforModifierlbl setTextAlignment:NSTextAlignmentLeft];
        [ModifierGroupView addSubview:chargeforModifierlbl];
        ForceBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        ForceBtn.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10+ChargeforModifierBtn.frame.size.width+10+chargeforModifierlbl.frame.size.width,325,30, 30);
        
        [ForceBtn addTarget:self action:@selector(BarBtnClicked) forControlEvents:UIControlEventTouchUpInside];
        [ForceBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [ForceBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
    [ForceBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
        [ModifierGroupView addSubview:ForceBtn];
        
        
        Forcelbl=[[UILabel alloc] init];
        Forcelbl.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10+ChargeforModifierBtn.frame.size.width+10+chargeforModifierlbl.frame.size.width+40,323,widthfield5, 40);
        
        [Forcelbl setFont:[UIFont systemFontOfSize:20.0f]];
        [Forcelbl setBackgroundColor:[UIColor clearColor]];
        [Forcelbl setTextColor:[UIColor whiteColor]];
        [Forcelbl setText:@"Forced?"];
        [Forcelbl setTextAlignment:NSTextAlignmentLeft];
        [ModifierGroupView addSubview:Forcelbl];
        
        SaveGroupModifierBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        SaveGroupModifierBtn.frame=CGRectMake(widthfield5+60,400,80,40);
        [SaveGroupModifierBtn addTarget:self action:@selector(SaveProductData) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [SaveGroupModifierBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [SaveGroupModifierBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [ModifierGroupView addSubview:SaveGroupModifierBtn];
        
        CancelGroupModifierBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        CancelGroupModifierBtn.frame=CGRectMake(widthfield5+260,400,80,40);
        [CancelGroupModifierBtn addTarget:self action:@selector(GropumodifierCancelclicked) forControlEvents:UIControlEventTouchUpInside];
        [CancelGroupModifierBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [CancelGroupModifierBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [ModifierGroupView addSubview:CancelGroupModifierBtn];
        
    ModIndividualView=[[UIView alloc] init];
        ModIndividualView.frame=CGRectMake(0,100 , ModifierView.frame.size.width, ModifierView.frame.size.height-200);
        
        [ModIndividualView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        
      
        
        CGFloat widthfield6=(ModIndividualView.frame.size.width)/4;
        CGFloat Ind=(widthfield6/2)+100;
        if (isLandScope)
        {
            ModifierIndividualTable = [[UITableView alloc] initWithFrame:CGRectMake(Ind,0,widthfield6+450, 350) style:UITableViewStylePlain];
        }
        else
        {
            ModifierIndividualTable = [[UITableView alloc] initWithFrame:CGRectMake(Ind,0,widthfield6+300, 350) style:UITableViewStylePlain];
        }
        ModifierIndividualTable.backgroundColor=[UIColor whiteColor];
        ModifierIndividualTable.delegate = self;
        ModifierIndividualTable.dataSource = self;
        ModifierIndividualTable.scrollEnabled = YES;
        [ModifierIndividualTable.layer setBorderWidth: 2.0];
        [ModifierIndividualTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [ModIndividualView addSubview:ModifierIndividualTable];

        
        
        AddModifierBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [AddModifierBtn setTitle:@"Add Modifier" forState:UIControlStateNormal];
        [AddModifierBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
        
        AddModifierBtn.frame=CGRectMake(40,130,widthfield6-80,80);
        [AddModifierBtn addTarget:self action:@selector(infoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
        AddModifierBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
        AddModifierBtn.titleLabel.numberOfLines = 2;
        AddModifierBtn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
        [AddModifierBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        [ModIndividualView addSubview:AddModifierBtn];
        
        SaveIndividualBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        SaveIndividualBtn.frame=CGRectMake(widthfield6+60,400,80,40);
        [SaveIndividualBtn addTarget:self action:@selector(SaveProductData) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [SaveIndividualBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [SaveIndividualBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [ModIndividualView addSubview:SaveIndividualBtn];
        
        CancelIndividualBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        CancelIndividualBtn.frame=CGRectMake(widthfield6+260,400,80,40);
        [CancelIndividualBtn addTarget:self action:@selector(IndividualmodifierCancelclicked) forControlEvents:UIControlEventTouchUpInside];
        [CancelIndividualBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [CancelIndividualBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [ModIndividualView addSubview:CancelIndividualBtn];
    }*/
else if (selectedButton==104){
        PriceLevelsBackView=[[UIView alloc]init];
        if (isLandScope) {
            PriceLevelsBackView.frame=CGRectMake(0, 0, 1024, 768);
        }
        
        else{
            
            PriceLevelsBackView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [PriceLevelsBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:PriceLevelsBackView];
        
        PriceLevelsView=[[UIView alloc] init];
        PriceLevelsView.frame=CGRectMake(50, 50, PriceLevelsBackView.frame.size.width-100, PriceLevelsBackView.frame.size.height-100);
        
        [PriceLevelsView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [PriceLevelsView.layer setBorderWidth:2.0];
        [PriceLevelsView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [PriceLevelsBackView addSubview:PriceLevelsView];
        
        CGFloat widthfield7=(PriceLevelsView.frame.size.width)/4;
        
        PriceLevelTextlbl=[[UILabel alloc] init];
        PriceLevelTextlbl.frame=CGRectMake(40,5,PriceLevelsView.frame.size.width-80,40);
        [PriceLevelTextlbl setFont:[UIFont systemFontOfSize:23.0f]];
        [PriceLevelTextlbl setBackgroundColor:[UIColor clearColor]];
        [PriceLevelTextlbl setTextColor:[UIColor whiteColor]];
        [PriceLevelTextlbl setText:@"Customers can automatically be charged one of 26 price levels"];
        PriceLevelTextlbl.lineBreakMode = NSLineBreakByWordWrapping;
        PriceLevelTextlbl.numberOfLines = 3;
        [PriceLevelTextlbl setTextAlignment:NSTextAlignmentLeft];
        [PriceLevelsView addSubview:PriceLevelTextlbl];
        
        
 PriceLevelsTable = [[UITableView alloc] initWithFrame:CGRectMake(10,40,PriceLevelsView.frame.size.width-20, 350) style:UITableViewStylePlain];
    
    PriceLevelsTable.backgroundColor=[UIColor whiteColor];
    PriceLevelsTable.delegate = self;
    PriceLevelsTable.dataSource = self;
    PriceLevelsTable.scrollEnabled = YES;
    [PriceLevelsTable.layer setBorderWidth: 2.0];
    [PriceLevelsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
    [PriceLevelsView addSubview:PriceLevelsTable];
        
        SavePriceLevelLbl = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        SavePriceLevelLbl.frame=CGRectMake(widthfield7+130,420,80,30);
        [SavePriceLevelLbl addTarget:self action:@selector(SaveProductData) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [SavePriceLevelLbl setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[SavePriceLevelLbl setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
    [SavePriceLevelLbl setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        [PriceLevelsView addSubview:SavePriceLevelLbl];
        
        CancelPricelevelbtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        CancelPricelevelbtn.frame=CGRectMake(widthfield7+240,420,80,30);
        [CancelPricelevelbtn addTarget:self action:@selector(PricelevelCancelclicked) forControlEvents:UIControlEventTouchUpInside];
        [CancelPricelevelbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[CancelPricelevelbtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
         [CancelPricelevelbtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [PriceLevelsView addSubview:CancelPricelevelbtn];
    }
}

}
-(void)infoButton2Clicked:(UIButton *)sender
{
    NSString *num=ItemNumberField.text;
    if ([num length]<=0)
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Please Enter Item Number" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        alert=nil;
    }
    else
    {
        NSInteger selectedbtn=sender.tag;
        if (selectedbtn==100){
            if (!OrderingInfoBackView)
                OrderingInfoBackView=[[UIView alloc]init];
            if (isLandScope) {
                OrderingInfoBackView.frame=CGRectMake(0, 0, 1024, 768);
            }
            
            else{
                
                OrderingInfoBackView.frame=CGRectMake(0, 0, 768, 1024);
            }
            [OrderingInfoBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
            [self.view addSubview:OrderingInfoBackView];
            if (!OrderingInfoView)
                OrderingInfoView=[[UIView alloc] init];
            if (isLandScope) {
                OrderingInfoView.frame=CGRectMake(50, 50, OrderingInfoBackView.frame.size.width-100, OrderingInfoBackView.frame.size.height-100);
            }
            else
            {
                OrderingInfoView.frame=CGRectMake(50, 150, OrderingInfoBackView.frame.size.width-100, OrderingInfoBackView.frame.size.height-400);
            }
            
            [OrderingInfoView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
            [OrderingInfoView.layer setBorderWidth:2.0];
            [OrderingInfoView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
            [OrderingInfoBackView addSubview:OrderingInfoView];
            if (!OpVendorsArray)
                OpVendorsArray=[[NSMutableArray alloc]init];
            NSString *querySQL = [NSString stringWithFormat: @"SELECT vendor_company_name FROM vendor"];
            NSMutableArray *venodrsArray=[[NSMutableArray alloc]init];
            [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:venodrsArray];
            
            for (NSDictionary *myDict in venodrsArray)
            {
                [OpVendorsArray addObject:[myDict objectForKey:@"vendor_company_name"]];
            }
            // //NSLog(@"%@",OpVendorsArray);
            
            CGFloat widthfield4=(OrderingInfoView.frame.size.width)/4;
            if (!OrderingInfotextLbl)
                OrderingInfotextLbl=[[UILabel alloc] init];
            OrderingInfotextLbl.frame=CGRectMake(widthfield4+100,10,widthfield4+100,40);
            [OrderingInfotextLbl setFont:[UIFont systemFontOfSize:25.0f]];
            [OrderingInfotextLbl setBackgroundColor:[UIColor clearColor]];
            [OrderingInfotextLbl setTextColor:[UIColor whiteColor]];
            [OrderingInfotextLbl setText:@"OrderingInfo Details"];
            [OrderingInfotextLbl setTextAlignment:NSTextAlignmentLeft];
            [OrderingInfoView addSubview:OrderingInfotextLbl];
            
            if (!Addvendorlbl)
                Addvendorlbl=[[UILabel alloc] init];
            Addvendorlbl.frame=CGRectMake(10, 125,widthfield4, 100);
            [Addvendorlbl setFont:[UIFont systemFontOfSize:20.0f]];
            [Addvendorlbl setBackgroundColor:[UIColor clearColor]];
            [Addvendorlbl setTextColor:[UIColor whiteColor]];
            
            [Addvendorlbl setText:@"Add Pricing From Vendor"];
            Addvendorlbl.lineBreakMode = NSLineBreakByWordWrapping;
            Addvendorlbl.numberOfLines = 2;
            [Addvendorlbl setTextAlignment:NSTextAlignmentLeft];
            [OrderingInfoView addSubview:Addvendorlbl];
            
            AddOpVendorBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            AddOpVendorBtn.frame=CGRectMake(Addvendorlbl.frame.size.width, 150,widthfield4+10, 40);
            [AddOpVendorBtn addTarget:self action:@selector(AddOpVendorClicked) forControlEvents:UIControlEventTouchUpInside];
            [AddOpVendorBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            //[AddOpVendorBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
            
            [AddOpVendorBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [OrderingInfoView addSubview:AddOpVendorBtn];
            
            
            if (!OpVendorslistTable)
                OpVendorslistTable = [[UITableView alloc] initWithFrame:CGRectMake(Addvendorlbl.frame.size.width, 50,widthfield4+10, 100) style:UITableViewStylePlain];
            OpVendorslistTable.backgroundColor=[UIColor whiteColor];
            OpVendorslistTable.delegate = self;
            OpVendorslistTable.dataSource = self;
            OpVendorslistTable.scrollEnabled = YES;
            OpVendorslistTable.hidden=YES;
            [OpVendorslistTable.layer setBorderWidth: 1.0];
            [OpVendorslistTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
            [OrderingInfoView addSubview:OpVendorslistTable];
            
            
            if (!OrderingInfoTable)
                OrderingInfoTable = [[UITableView alloc] initWithFrame:CGRectMake(10, 200,OrderingInfoView.frame.size.width-20, 300) style:UITableViewStylePlain];
            OrderingInfoTable.backgroundColor=[UIColor whiteColor];
            OrderingInfoTable.delegate = self;
            OrderingInfoTable.dataSource = self;
            OrderingInfoTable.scrollEnabled = YES;
            
            [OrderingInfoTable.layer setBorderWidth: 1.0];
            [OrderingInfoTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
            [OrderingInfoView addSubview:OrderingInfoTable];
            
            @autoreleasepool {
                SaveOrderingInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
                
                SaveOrderingInfoBtn.frame=CGRectMake(widthfield4+120,540,80,30);
                [SaveOrderingInfoBtn addTarget:self action:@selector(SaveorderingInfo) forControlEvents:UIControlEventTouchUpInside];
                
                //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
                [SaveOrderingInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                //[SaveOrderingInfoBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
                [SaveOrderingInfoBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
                [OrderingInfoView addSubview:SaveOrderingInfoBtn];
                
                CancelOrderingInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
                
                CancelOrderingInfoBtn.frame=CGRectMake(widthfield4+220,540,80,30);
                [CancelOrderingInfoBtn addTarget:self action:@selector(CancelOrderingInfo) forControlEvents:UIControlEventTouchUpInside];
                [CancelOrderingInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                // [CancelOrderingInfoBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
                [CancelOrderingInfoBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
                // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
                [OrderingInfoView addSubview:CancelOrderingInfoBtn];
            }
        }else if (selectedbtn==101){
            if (!HistoryPopupView)
                HistoryPopupView=[[UIView alloc]init];
            if (isLandScope) {
                HistoryPopupView.frame=CGRectMake(0, 0, 1024, 768);
            }else{
                
                HistoryPopupView.frame=CGRectMake(0, 0, 768, 1024);
            }
            [HistoryPopupView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
            [self.view addSubview:HistoryPopupView];
            if (!HistoryView)
                HistoryView=[[UIView alloc] init];
            if (isLandScope)
            {
                HistoryView.frame=CGRectMake(50, 100, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-200);
            }
            else
            {
                HistoryView.frame=CGRectMake(50, 150, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-400);
            }
            
            
            [HistoryView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
            [HistoryView.layer setBorderWidth:2.0];
            [HistoryView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
            [HistoryPopupView addSubview:HistoryView];
            
            
            CGFloat widthfield5=(HistoryView.frame.size.width)/4;
            if (!Historytextlbl)
                Historytextlbl=[[UILabel alloc] init];
            Historytextlbl.frame=CGRectMake(widthfield5+120,10,widthfield5,40);
            [Historytextlbl setFont:[UIFont systemFontOfSize:25.0f]];
            [Historytextlbl setBackgroundColor:[UIColor clearColor]];
            [Historytextlbl setTextColor:[UIColor whiteColor]];
            [Historytextlbl setText:@"Sales History"];
            [Historytextlbl setTextAlignment:NSTextAlignmentLeft];
            [HistoryView addSubview:Historytextlbl];
            if (!SalesHistoryTable)
                SalesHistoryTable = [[UITableView alloc] initWithFrame:CGRectMake(10,60,HistoryView.frame.size.width-20, 400) style:UITableViewStylePlain];
            SalesHistoryTable.backgroundColor=[UIColor clearColor];
            SalesHistoryTable.delegate = self;
            SalesHistoryTable.dataSource = self;
            SalesHistoryTable.scrollEnabled = YES;
            
            [SalesHistoryTable.layer setBorderWidth: 1.0];
            [SalesHistoryTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
            [HistoryView addSubview:SalesHistoryTable];
            
            saveHistoryBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            saveHistoryBtn.frame=CGRectMake(widthfield5+160,500,80,30);
            [saveHistoryBtn addTarget:self action:@selector(Savehistory) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [saveHistoryBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[saveHistoryBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [saveHistoryBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            [HistoryView addSubview:saveHistoryBtn];
            
            NSString *querySQL1 = [NSString stringWithFormat: @"SELECT item_id, discount,total_tax,item_name,item_desscription,price_you_charge,avg_cost,item_quantity,invoice_id,unique_id,created_timestamp,payment_type,in_department,in_vendor,store_id,status,employee,customer FROM invoice_items_table WHERE item_id='%@'",InvItemNumber];
            
            invoiceItemsArray=[[NSMutableArray alloc]init];
            [[DataBaseManager dataBaseManager]execute:querySQL1 resultsArray:invoiceItemsArray];
            
            itemIDArray=[[NSMutableArray alloc]init];
            for (NSDictionary *myDict in invoiceItemsArray)
            {
                [itemIDArray addObject:[myDict objectForKey:@"item_id"]];
            }
            SnosArray=[[NSMutableArray alloc]init];
            
            for (int i=1;i<=[itemIDArray count] ; i++)
            {
                [SnosArray  addObject:[NSString stringWithFormat:@"%d",i]];
                
            }
        }
        
    }
    
}
-(void)ChangeinfoButton1Clicked:(UIButton *)sender
{
    NSInteger selectedButton=sender.tag;
    
    if (selectedButton==100){
        SkusArray=SelectedSkusArray;
        if (!OptionalInfoBackView)
            OptionalInfoBackView=[[UIView alloc]init];
        if (isLandScope) {
            OptionalInfoBackView.frame=CGRectMake(0, 0, 1024, 768);
        }
        
        else{
            
            OptionalInfoBackView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [OptionalInfoBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:OptionalInfoBackView];
        if (!OptionalInfoView)
            OptionalInfoView=[[UIView alloc] init];
        if (isLandScope)
        {
            OptionalInfoView.frame=CGRectMake(50, 50, OptionalInfoBackView.frame.size.width-100, OptionalInfoBackView.frame.size.height-100);
        }
        else
        {
            OptionalInfoView.frame=CGRectMake(50, 150, OptionalInfoBackView.frame.size.width-100, OptionalInfoBackView.frame.size.height-400);
        }
        
        [OptionalInfoView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [OptionalInfoView.layer setBorderWidth:2.0];
        [OptionalInfoView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [OptionalInfoBackView addSubview:OptionalInfoView];
        
        CGFloat widthfield=(OptionalInfoView.frame.size.width)/4;
        CGFloat o=(widthfield/2);
        if (!OptionalinfoTextLbl)
            OptionalinfoTextLbl=[[UILabel alloc] init];
        OptionalinfoTextLbl.frame=CGRectMake(widthfield+60,10,widthfield+100, 40);
        [OptionalinfoTextLbl setFont:[UIFont systemFontOfSize:20.0f]];
        [OptionalinfoTextLbl setBackgroundColor:[UIColor clearColor]];
        [OptionalinfoTextLbl setTextColor:[UIColor whiteColor]];
        [OptionalinfoTextLbl setText:@"Optional Info Details"];
        [OptionalinfoTextLbl setTextAlignment:NSTextAlignmentLeft];
        [OptionalInfoView addSubview:OptionalinfoTextLbl];
        int w=60;
        
        for (int i=0; i<5; i++)
        {
            
            Optionalinfolbl=[[UILabel alloc] init];
            Optionalinfolbl.frame=CGRectMake(o-80, w,widthfield+10, 40);
            
            Optionalinfolbl.tag=i+100;
            [Optionalinfolbl setFont:[UIFont systemFontOfSize:20.0f]];
            [Optionalinfolbl setBackgroundColor:[UIColor clearColor]];
            [Optionalinfolbl setTextColor:[UIColor whiteColor]];
            NSArray *labelArray=[[NSArray alloc] initWithObjects:@"Bonus Points",@"Barcodes",@"Location",@"UnitSize ",@"Unit Type",nil];
            [Optionalinfolbl setText:[labelArray objectAtIndex:i]];
            [Optionalinfolbl setTextAlignment:NSTextAlignmentLeft];
            [OptionalInfoView addSubview:Optionalinfolbl];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            OptionalinfoFields=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            if (isLandScope) {
                OptionalinfoFields.frame=CGRectMake(o+Optionalinfolbl.frame.size.width-150, w,widthfield-60, 40);
            }
            else
            {
                OptionalinfoFields.frame=CGRectMake(o+Optionalinfolbl.frame.size.width-130, w,widthfield-60, 40);
                
            }
            
            OptionalinfoFields.delegate=self;
            OptionalinfoFields.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            OptionalinfoFields.leftView = paddingview;
            OptionalinfoFields.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            OptionalinfoFields.leftViewMode = UITextFieldViewModeAlways;
            //[OptionalinfoFields setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
            [OptionalinfoFields setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
            
            paddingview=nil;
            
            if (OptionalinfoFields.tag==100)
            {
                OptionalinfoFields.text=Editbonuspoint;
            }
            if (OptionalinfoFields.tag==101)
            {
                OptionalinfoFields.text=Editbarcode;
            }
            if (OptionalinfoFields.tag==102)
            {
                OptionalinfoFields.text=Editlocation;
            }
            if (OptionalinfoFields.tag==103)
            {
                OptionalinfoFields.text=Editunitsize;
            }
            if (OptionalinfoFields.tag==104)
            {
                OptionalinfoFields.text=EditUnittype;
            }
            [OptionalinfoFields addTarget:self action:@selector(EditOptionallinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
            [OptionalinfoFields setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [OptionalInfoView addSubview:OptionalinfoFields];
            
            w=w+60;
            
        }
        if (!OptCommissonlbl)
            OptCommissonlbl=[[UILabel alloc] init];
        OptCommissonlbl.frame=CGRectMake(o-80,360,widthfield+10, 40);
        [OptCommissonlbl setFont:[UIFont systemFontOfSize:20.0f]];
        [OptCommissonlbl setBackgroundColor:[UIColor clearColor]];
        [OptCommissonlbl setTextColor:[UIColor whiteColor]];
        [OptCommissonlbl setText:@"Commission"];
        [OptCommissonlbl setTextAlignment:NSTextAlignmentLeft];
        [OptionalInfoView addSubview:OptCommissonlbl];
        if (!optCommissionBtn)
            optCommissionBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        optCommissionBtn.frame=CGRectMake(widthfield-30, 360,widthfield-60, 40);
        [optCommissionBtn addTarget:self action:@selector(CommisionBtnClicked) forControlEvents:UIControlEventTouchUpInside];
        [optCommissionBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        //[optCommissionBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
        [optCommissionBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
        
        [optCommissionBtn setTitle:Editcommission forState:UIControlStateNormal];
        [OptionalInfoView addSubview:optCommissionBtn];
        if (!CommissionsTable)
            CommissionsTable = [[UITableView alloc] initWithFrame:CGRectMake(widthfield-30, 400,widthfield-60, 100) style:UITableViewStylePlain];
        CommissionsTable.backgroundColor=[UIColor whiteColor];
        CommissionsTable.delegate = self;
        CommissionsTable.dataSource = self;
        CommissionsTable.hidden=YES;
        CommissionsTable.scrollEnabled = YES;
        [CommissionsTable.layer setBorderWidth: 1.0];
        [CommissionsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [OptionalInfoView addSubview:CommissionsTable];
        if (!Alternatelbl)
            Alternatelbl=[[UILabel alloc] init];
        Alternatelbl.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width-10,60,widthfield+10, 40);
        [Alternatelbl setFont:[UIFont systemFontOfSize:20.0f]];
        [Alternatelbl setBackgroundColor:[UIColor clearColor]];
        [Alternatelbl setTextColor:[UIColor whiteColor]];
        [Alternatelbl setText:@"Alternate SKUs"];
        [Alternatelbl setTextAlignment:NSTextAlignmentLeft];
        [OptionalInfoView addSubview:Alternatelbl];
        if (!AlternateTable)
            AlternateTable = [[UITableView alloc] initWithFrame:CGRectMake(widthfield+optCommissionBtn.frame.size.width-10,95,widthfield+80, 100) style:UITableViewStylePlain];
        AlternateTable.backgroundColor=[UIColor whiteColor];
        AlternateTable.delegate = self;
        AlternateTable.dataSource = self;
        AlternateTable.scrollEnabled = YES;
        [AlternateTable.layer setBorderWidth: 1.0];
        [AlternateTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [OptionalInfoView addSubview:AlternateTable];
        
        if (!AddskuBtn)
            AddskuBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [AddskuBtn setTitle:@"Add Alternate Sku's" forState:UIControlStateNormal];
        //[AddskuBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
        [AddskuBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]] forState:UIControlStateNormal];
        
        AddskuBtn.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width+Alternatelbl.frame.size.width+80,100,widthfield-50, 80);
        [AddskuBtn addTarget:self action:@selector(AddskusClicked) forControlEvents:UIControlEventTouchUpInside];
        AddskuBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
        AddskuBtn.titleLabel.numberOfLines = 2;
        AddskuBtn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
        [AddskuBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        [OptionalInfoView addSubview:AddskuBtn];
        NSArray *labelArray;
        if (!labelArray)
            labelArray=[[NSArray alloc] initWithObjects:@"Modifier Item",@"Count This Item",@"Prompt Quantity",@"Print On Receipt",@"Foodstampable",@"Prompt price",nil];
        
        int z=210;
        for (int i=0; i<6; i++)
        {
            
            
            ItemBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            ItemBtn.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width-10,z,30, 30);
            ItemBtn.tag=i+100;
            [ItemBtn addTarget:self action:@selector(DuplicateItemBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
            [ItemBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            //[ItemBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
            // [ItemBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
            [ItemBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
            [ItemBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
            
            [OptionalInfoView addSubview:ItemBtn];
            Itemlbl=[[UILabel alloc] init];
            if (isLandScope)
            {
                Itemlbl.frame=CGRectMake(widthfield+ItemBtn.frame.size.width+170, z-5,widthfield+10, 40);
            }
            else
            {
                Itemlbl.frame=CGRectMake(widthfield+ItemBtn.frame.size.width+120, z-5,widthfield+10, 40);
            }
            if (ItemBtn.tag==100)
            {
                
                if ([EditmodifierItem isEqualToString:@"yes"])
                {
                    ItemBtn.selected=YES;
                    EditmodifierItem=@"yes";
                }
                else
                {
                    ItemBtn.selected=NO;
                    EditmodifierItem=@"no";
                }
            }
            if (ItemBtn.tag==101)
            {
                
                if ([EditCountthisItem isEqualToString:@"yes"])
                {
                    ItemBtn.selected=YES;
                    EditCountthisItem=@"yes";
                }
                else
                {
                    ItemBtn.selected=NO;
                    EditCountthisItem=@"no";
                }
            }
            if (ItemBtn.tag==102)
            {
                
                if ([Editallowbuyback isEqualToString:@"yes"])
                {
                    ItemBtn.selected=YES;
                    Editallowbuyback=@"yes";
                }
                else
                {
                    ItemBtn.selected=NO;
                    Editallowbuyback=@"no";
                }
            }
            if (ItemBtn.tag==103)
            {
                
                if ([Editprintonreceipt isEqualToString:@"yes"])
                {
                    ItemBtn.selected=YES;
                    Editprintonreceipt=@"yes";
                }
                else
                {
                    ItemBtn.selected=NO;
                    Editprintonreceipt=@"no";
                }
            }
            if (ItemBtn.tag==104)
            {
                
                if ([Editfoodstampable isEqualToString:@"yes"])
                {
                    ItemBtn.selected=YES;
                    Editfoodstampable=@"yes";
                    
                }
                else
                {
                    ItemBtn.selected=NO;
                    Editfoodstampable=@"no";
                }
            }
            if (ItemBtn.tag==105)
            {
                
                if ([Editpromptprice isEqualToString:@"yes"])
                {
                    ItemBtn.selected=YES;
                    Editpromptprice=@"yes";
                    
                }
                else
                {
                    ItemBtn.selected=NO;
                    Editpromptprice=@"no";
                }
            }
            Itemlbl.tag=i+100;
            [Itemlbl setFont:[UIFont systemFontOfSize:20.0f]];
            [Itemlbl setBackgroundColor:[UIColor clearColor]];
            [Itemlbl setTextColor:[UIColor whiteColor]];
            
            [Itemlbl setText:[labelArray objectAtIndex:i]];
            [Itemlbl setTextAlignment:NSTextAlignmentLeft];
            [OptionalInfoView addSubview:Itemlbl];
            z=z+40;
            
        }
        
        @autoreleasepool {
            OptionalinfoSaveBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            OptionalinfoSaveBtn.frame=CGRectMake(widthfield+120,520,80,30);
            [OptionalinfoSaveBtn addTarget:self action:@selector(SaveEditOptionalInfo) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [OptionalinfoSaveBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[OptionalinfoSaveBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [OptionalinfoSaveBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            [OptionalInfoView addSubview:OptionalinfoSaveBtn];
            
            OptionalinfoCancelBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            OptionalinfoCancelBtn.frame=CGRectMake(widthfield+220,520,80,30);
            [OptionalinfoCancelBtn addTarget:self action:@selector(OptionalInfoCancelclicked) forControlEvents:UIControlEventTouchUpInside];
            [OptionalinfoCancelBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[OptionalinfoCancelBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            
            [OptionalinfoCancelBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [OptionalInfoView addSubview:OptionalinfoCancelBtn];
        }
        
    }
    /*   if (selectedButton==101)
     {
     PendingOrderBackView=[[UIView alloc]init];
     if (isLandScope) {
     PendingOrderBackView.frame=CGRectMake(0, 0, 1024, 768);
     }
     
     else{
     
     PendingOrderBackView.frame=CGRectMake(0, 0, 768, 1024);
     }
     [PendingOrderBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
     [self.view addSubview:PendingOrderBackView];
     
     PendingOrderView=[[UIView alloc] init];
     PendingOrderView.frame=CGRectMake(50, 50, PendingOrderBackView.frame.size.width-100, PendingOrderBackView.frame.size.height-100);
     
     [PendingOrderView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
     
     [PendingOrderBackView addSubview:PendingOrderView];
     
     
     CGFloat widthfield2=(PendingOrderView.frame.size.width)/4;
     CGFloat pen=(widthfield2/2);
     PendingOrderTextlbl=[[UILabel alloc] init];
     PendingOrderTextlbl.frame=CGRectMake(widthfield2+60,10,widthfield2+200, 40);
     [PendingOrderTextlbl setFont:[UIFont systemFontOfSize:22.0f]];
     [PendingOrderTextlbl setBackgroundColor:[UIColor clearColor]];
     [PendingOrderTextlbl setTextColor:[UIColor whiteColor]];
     [PendingOrderTextlbl setText:@"Pending Order Details"];
     [PendingOrderTextlbl setTextAlignment:NSTextAlignmentLeft];
     [PendingOrderView addSubview:PendingOrderTextlbl];
     OpenRadioBtn = [[UIButton alloc] init];
     OpenRadioBtn.frame=CGRectMake(pen-60, 60, 25, 25);
     [OpenRadioBtn setTag:0];
     [OpenRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
     [OpenRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
     
     [OpenRadioBtn addTarget:self action:@selector(OpenRadioBtnClciked) forControlEvents:UIControlEventTouchUpInside];
     [PendingOrderView addSubview:OpenRadioBtn];
     openlbl=[[UILabel alloc] init];
     openlbl.frame=CGRectMake(pen-60+OpenRadioBtn.frame.size.width+5,55,widthfield2,40);
     [openlbl setFont:[UIFont systemFontOfSize:20.0f]];
     [openlbl setBackgroundColor:[UIColor clearColor]];
     [openlbl setTextColor:[UIColor whiteColor]];
     [openlbl setText:@"Open"];
     OpenRadioBtn.selected=YES;
     [openlbl setTextAlignment:NSTextAlignmentLeft];
     [PendingOrderView addSubview:openlbl];
     
     
     CompleteRadioBtn = [[UIButton alloc] init];
     CompleteRadioBtn.frame=CGRectMake(pen-60+openlbl.frame.size.width, 60, 25, 25);
     [CompleteRadioBtn setTag:1];
     [CompleteRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
     [CompleteRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
     [CompleteRadioBtn addTarget:self action:@selector(CompleteRadioBtnClicked) forControlEvents:UIControlEventTouchUpInside];
     [PendingOrderView addSubview:CompleteRadioBtn];
     
     completelbl=[[UILabel alloc] init];
     completelbl.frame=CGRectMake(pen-35+openlbl.frame.size.width,55,widthfield2,40);
     [completelbl setFont:[UIFont systemFontOfSize:20.0f]];
     [completelbl setBackgroundColor:[UIColor clearColor]];
     [completelbl setTextColor:[UIColor whiteColor]];
     [completelbl setText:@"Complete"];
     [completelbl setTextAlignment:NSTextAlignmentLeft];
     [PendingOrderView addSubview:completelbl];
     
     CancelRadioBtn = [[UIButton alloc] init];
     CancelRadioBtn.frame=CGRectMake(pen-60+openlbl.frame.size.width+completelbl.frame.size.width+20, 60, 25, 25);
     [CancelRadioBtn setTag:2];
     [CancelRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
     [CancelRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
     [CancelRadioBtn addTarget:self action:@selector(CancelRadioBtnClicked) forControlEvents:UIControlEventTouchUpInside];
     [PendingOrderView addSubview:CancelRadioBtn];
     
     cancellbl=[[UILabel alloc] init];
     cancellbl.frame=CGRectMake(pen-35+openlbl.frame.size.width+completelbl.frame.size.width+20,55,widthfield2,40);
     [cancellbl setFont:[UIFont systemFontOfSize:20.0f]];
     [cancellbl setBackgroundColor:[UIColor clearColor]];
     [cancellbl setTextColor:[UIColor whiteColor]];
     [cancellbl setText:@"Cancel"];
     [cancellbl setTextAlignment:NSTextAlignmentLeft];
     [PendingOrderView addSubview:cancellbl];
     
     PendingOrdersTable = [[UITableView alloc] initWithFrame:CGRectMake(pen-60,95,widthfield2+450, 400) style:UITableViewStylePlain];
     PendingOrdersTable.backgroundColor=[UIColor whiteColor];
     PendingOrdersTable.delegate = self;
     PendingOrdersTable.dataSource = self;
     PendingOrdersTable.scrollEnabled = YES;
     [PendingOrdersTable.layer setBorderWidth: 2.0];
     [PendingOrdersTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
     [PendingOrderView addSubview:PendingOrdersTable];
     
     //        CompletethisorderBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     //
     //        [CompletethisorderBtn setTitle:@"Complete This Order" forState:UIControlStateNormal];
     //        [CompletethisorderBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
     //        CompletethisorderBtn.frame=CGRectMake(PendingOrdersTable.frame.size.width+60,170,100, 100);
     //        [CompletethisorderBtn addTarget:self action:@selector(infoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
     //          CompletethisorderBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
     //        CompletethisorderBtn.titleLabel.numberOfLines = 2;
     //        CompletethisorderBtn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
     //        [CompletethisorderBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     //
     //        [PendingOrderView addSubview:CompletethisorderBtn];
     //        cancelthisOrderBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     //
     //        [cancelthisOrderBtn setTitle:@"Cancel This Order" forState:UIControlStateNormal];
     //        [cancelthisOrderBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
     //        cancelthisOrderBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
     //        cancelthisOrderBtn.frame=CGRectMake(PendingOrdersTable.frame.size.width+60,340,100, 100);
     //        [cancelthisOrderBtn addTarget:self action:@selector(infoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
     //        cancelthisOrderBtn.titleLabel.numberOfLines = 2;
     //        cancelthisOrderBtn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
     //        [cancelthisOrderBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     //
     //        [PendingOrderView addSubview:cancelthisOrderBtn];
     
     SavePendingorderBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     SavePendingorderBtn.frame=CGRectMake(widthfield2+40,520,80,40);
     [SavePendingorderBtn addTarget:self action:@selector(SaveProductData) forControlEvents:UIControlEventTouchUpInside];
     
     //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
     [SavePendingorderBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
     [SavePendingorderBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
     [PendingOrderView addSubview:SavePendingorderBtn];
     
     CancelPendingorderBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     CancelPendingorderBtn.frame=CGRectMake(widthfield2+240,520,80,40);
     [CancelPendingorderBtn addTarget:self action:@selector(PendingInfoCancelclicked) forControlEvents:UIControlEventTouchUpInside];
     [CancelPendingorderBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
     [CancelPendingorderBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
     // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
     [PendingOrderView addSubview:CancelPendingorderBtn];
     
     }*/
    else if (selectedButton==101){
        if (!NotesBackView)
            NotesBackView=[[UIView alloc]init];
        if (isLandScope) {
            NotesBackView.frame=CGRectMake(0, 0, 1024, 768);
        }
        
        else{
            
            NotesBackView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [NotesBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:NotesBackView];
        if (!NotesView)
            NotesView=[[UIView alloc] init];
        if (isLandScope)
        {
            NotesView.frame=CGRectMake(50, 50, NotesBackView.frame.size.width-100, NotesBackView.frame.size.height-100);
        }
        else
        {
            NotesView.frame=CGRectMake(50, 150, NotesBackView.frame.size.width-100, NotesBackView.frame.size.height-400);
        }
        
        [NotesView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [NotesView.layer setBorderWidth:2.0];
        [NotesView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [NotesBackView addSubview:NotesView];
        
        CGFloat widthfield3=(NotesView.frame.size.width)/4;
        if (!Notestextlbl)
            Notestextlbl=[[UILabel alloc] init];
        Notestextlbl.frame=CGRectMake(10,10,NotesView.frame.size.width-50,140);
        [Notestextlbl setFont:[UIFont systemFontOfSize:20.0f]];
        [Notestextlbl setBackgroundColor:[UIColor clearColor]];
        [Notestextlbl setTextColor:[UIColor whiteColor]];
        [Notestextlbl setText:@"You can enter notes to describe your item.This can be used to describe instructions to care for a plant,ingredients inside a meal,or other useful information."];
        Notestextlbl.lineBreakMode = NSLineBreakByWordWrapping;
        Notestextlbl.numberOfLines = 3;
        [Notestextlbl setTextAlignment:NSTextAlignmentLeft];
        [NotesView addSubview:Notestextlbl];
        if (!NotesTextView)
            NotesTextView=[[UITextView alloc] init];
        NotesTextView.frame=CGRectMake(10, 115,NotesView.frame.size.width-20,400);
        NotesTextView.delegate=self;
        NotesTextView.text=EditProductNotes;
        NotesTextView.font=[UIFont systemFontOfSize:14.0f];
        [NotesTextView setAutocorrectionType:UITextAutocorrectionTypeNo];
        NotesTextView.layer.cornerRadius=8;
        [NotesView addSubview:NotesTextView];
        
        @autoreleasepool {
            SaveNotesBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SaveNotesBtn.frame=CGRectMake(widthfield3+120,540,80,30);
            [SaveNotesBtn addTarget:self action:@selector(SaveDuplicateProductNotes) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SaveNotesBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[SaveNotesBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [SaveNotesBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            [NotesView addSubview:SaveNotesBtn];
            
            CancelNotesBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelNotesBtn.frame=CGRectMake(widthfield3+220,540,80,30);
            [CancelNotesBtn addTarget:self action:@selector(NotesCancelclicked) forControlEvents:UIControlEventTouchUpInside];
            [CancelNotesBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[CancelNotesBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            
            [CancelNotesBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [NotesView addSubview:CancelNotesBtn];
            
        }
        
    }else if (selectedButton==102){
        
        // UIButton *ModifieritemsDropdownBtn,*SavemodBtn,*CancelModBtn;
        //UITableView *ItemsListTable,*modifierItemsTable;
        
        modifierNamesArray=SelectedNamesArray;
        ModifierItemNosArray=selectedModifiers;
        if (!modBackView)
            modBackView=[[UIView alloc]init];
        if (isLandScope) {
            modBackView.frame=CGRectMake(0, 0, 1024, 768);
        }
        
        else{
            
            modBackView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [modBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:modBackView];
        if (!modView)
            modView=[[UIView alloc] init];
        if (isLandScope)
        {
            modView.frame=CGRectMake(50, 50, modBackView.frame.size.width-100, modBackView.frame.size.height-100);
        }
        else
        {
            modView.frame=CGRectMake(50, 150, modBackView.frame.size.width-100, modBackView.frame.size.height-400);
        }
        
        
        
        [modView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [modView.layer setBorderWidth:2.0];
        [modView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [modBackView addSubview:modView];
        
        CGFloat Modwidthfield=(modView.frame.size.width)/2;
        if (!modTextlbl)
            modTextlbl=[[UILabel alloc] init];
        modTextlbl.frame=CGRectMake(Modwidthfield-100,5,Modwidthfield+200, 40);
        [modTextlbl setFont:[UIFont systemFontOfSize:22.0f]];
        [modTextlbl setBackgroundColor:[UIColor clearColor]];
        [modTextlbl setTextColor:[UIColor whiteColor]];
        [modTextlbl setText:@"Modifier List"];
        [modTextlbl setTextAlignment:NSTextAlignmentLeft];
        [modView addSubview:modTextlbl];
        
            ItemNumbersArray=[[NSMutableArray alloc]init];
            itemsListArray=[[NSMutableArray alloc]init];
            
            ItemnameArray=[[NSMutableArray alloc]init];
            NamesArray=[[NSMutableArray alloc]init];
            modifierItemsArray=[[NSMutableArray alloc]init];
       
        NSString *querySQL = [NSString stringWithFormat: @"SELECT inventary_modifier_item,inventory_item_no FROM optional_info_table "];
        NSMutableArray *optinfoArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:optinfoArray];
        
        
        NSString *prodquerySQL = [NSString stringWithFormat: @"SELECT inventary_item_name FROM inventorytable"];
        NSMutableArray *productArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:prodquerySQL resultsArray:productArray];
        if ([optinfoArray count]>0)
        {
            for (NSDictionary *myDict in optinfoArray)
            {
                
                [modifierItemsArray addObject:[myDict objectForKey:@"inventary_modifier_item"]];
                
                [ItemNumbersArray addObject:[myDict objectForKey:@"inventory_item_no"]];
                
                
            }
            for (NSDictionary *myDict in productArray)
            {
                [ItemnameArray addObject:[myDict objectForKey:@"inventary_item_name"]];
            }
            
            for (int i=0; i<[modifierItemsArray count]; i++)
            {
                NSString *mystr=[modifierItemsArray objectAtIndex:i];
                if ([mystr isEqualToString:@"yes"])
                {
                    NSString *item=[ItemNumbersArray objectAtIndex:i];
                    NSString *name=[ItemnameArray objectAtIndex:i];
                    [NamesArray addObject:name];
                    
                    [itemsListArray addObject:item];
                    item=name=nil;
                }
                mystr=nil;
            }
        }
        
        // //NSLog(@"%@",itemsListArray);
        if (!ModifieritemsDropdownBtn)
            ModifieritemsDropdownBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        ModifieritemsDropdownBtn.frame=CGRectMake(20, 50,Modwidthfield-150, 40);
        [ModifieritemsDropdownBtn addTarget:self action:@selector(ModifierItemClicked) forControlEvents:UIControlEventTouchUpInside];
        
        [ModifieritemsDropdownBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        //[ModifieritemsDropdownBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
        [ModifieritemsDropdownBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
        [modView addSubview:ModifieritemsDropdownBtn];
        if (!ItemsListTable)
        ItemsListTable = [[UITableView alloc] initWithFrame:CGRectMake(20, 90,Modwidthfield-150, 200) style:UITableViewStylePlain];
        ItemsListTable.backgroundColor=[UIColor whiteColor];
        ItemsListTable.delegate = self;
        ItemsListTable.dataSource = self;
        ItemsListTable.hidden=YES;
        ItemsListTable.scrollEnabled = YES;
        [ItemsListTable.layer setBorderWidth: 1.0];
        [ItemsListTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [modView addSubview:ItemsListTable];
        [ItemsListTable reloadData];
        if (!modifierItemsTable)
            modifierItemsTable = [[UITableView alloc] initWithFrame:CGRectMake(20+ModifieritemsDropdownBtn.frame.size.width+10, 40,modView.frame.size.width-(20+ModifieritemsDropdownBtn.frame.size.width+20), 400) style:UITableViewStylePlain];
        modifierItemsTable.backgroundColor=[UIColor whiteColor];
        modifierItemsTable.delegate = self;
        modifierItemsTable.dataSource = self;
        // modifierItemsTable.hidden=YES;
        modifierItemsTable.scrollEnabled = YES;
        [modifierItemsTable.layer setBorderWidth: 1.0];
        [modifierItemsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [modView addSubview:modifierItemsTable];
        [modifierItemsTable reloadData];
        @autoreleasepool {
            SavemodBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SavemodBtn.frame=CGRectMake(Modwidthfield-100,460,80,30);
            [SavemodBtn addTarget:self action:@selector(SaveModifierData) forControlEvents:UIControlEventTouchUpInside];
            [SavemodBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[SavemodBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [SavemodBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            [modView addSubview:SavemodBtn];
            
            CancelModBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelModBtn.frame=CGRectMake(Modwidthfield+30,460,80,30);
            [CancelModBtn addTarget:self action:@selector(ModifierCancelClicked) forControlEvents:UIControlEventTouchUpInside];
            [CancelModBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[CancelModBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            [CancelModBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [modView addSubview:CancelModBtn];
        }
        
        
    }
    
    /*if (selectedButton==102)
     {
     ModifierBackView=[[UIView alloc]init];
     if (isLandScope) {
     ModifierBackView.frame=CGRectMake(0, 0, 1024, 768);
     }
     
     else{
     
     ModifierBackView.frame=CGRectMake(0, 0, 768, 1024);
     }
     [ModifierBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
     [self.view addSubview:ModifierBackView];
     
     ModifierView=[[UIView alloc] init];
     ModifierView.frame=CGRectMake(50, 50, ModifierBackView.frame.size.width-100, ModifierBackView.frame.size.height-100);
     
     [ModifierView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
     
     [ModifierBackView addSubview:ModifierView];
     
     CGFloat widthfield4=(ModifierView.frame.size.width)/4;
     CGFloat mod=(widthfield4/2)+100;
     ModifierTextlbl=[[UILabel alloc] init];
     ModifierTextlbl.frame=CGRectMake(widthfield4+60,10,widthfield4+200, 40);
     [ModifierTextlbl setFont:[UIFont systemFontOfSize:22.0f]];
     [ModifierTextlbl setBackgroundColor:[UIColor clearColor]];
     [ModifierTextlbl setTextColor:[UIColor whiteColor]];
     [ModifierTextlbl setText:@"Modifier List"];
     [ModifierTextlbl setTextAlignment:NSTextAlignmentLeft];
     [ModifierView addSubview:ModifierTextlbl];
     
     GroupRadioBtn = [[UIButton alloc] init];
     GroupRadioBtn.frame=CGRectMake(mod, 60, 25, 25);
     [GroupRadioBtn setTag:1];
     [GroupRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
     [GroupRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
     [GroupRadioBtn addTarget:self action:@selector(GroupRadioBtnClicked) forControlEvents:UIControlEventTouchUpInside];
     GroupRadioBtn.selected=YES;
     [ModifierView addSubview:GroupRadioBtn];
     
     Grouplbl=[[UILabel alloc] init];
     Grouplbl.frame=CGRectMake(mod+GroupRadioBtn.frame.size.width+5,55,100,40);
     [Grouplbl setFont:[UIFont systemFontOfSize:20.0f]];
     [Grouplbl setBackgroundColor:[UIColor clearColor]];
     [Grouplbl setTextColor:[UIColor whiteColor]];
     [Grouplbl setText:@"Group"];
     [Grouplbl setTextAlignment:NSTextAlignmentLeft];
     [ModifierView addSubview:Grouplbl];
     
     IndividualRadioBtn = [[UIButton alloc] init];
     IndividualRadioBtn.frame=CGRectMake(mod+GroupRadioBtn.frame.size.width+Grouplbl.frame.size.width+20, 60, 25, 25);
     [IndividualRadioBtn setTag:1];
     [IndividualRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
     [IndividualRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
     [IndividualRadioBtn addTarget:self action:@selector(IndividualRadioBtnClicked) forControlEvents:UIControlEventTouchUpInside];
     [ModifierView addSubview:IndividualRadioBtn];
     individuallbl=[[UILabel alloc] init];
     individuallbl.frame=CGRectMake(mod+GroupRadioBtn.frame.size.width+Grouplbl.frame.size.width+50,55,200,40);
     [individuallbl setFont:[UIFont systemFontOfSize:20.0f]];
     [individuallbl setBackgroundColor:[UIColor clearColor]];
     [individuallbl setTextColor:[UIColor whiteColor]];
     [individuallbl setText:@"Individual Items"];
     [individuallbl setTextAlignment:NSTextAlignmentLeft];
     [ModifierView addSubview:individuallbl];
     
     ModifierGroupView=[[UIView alloc] init];
     ModifierGroupView.frame=CGRectMake(0,100 , ModifierView.frame.size.width, ModifierView.frame.size.height-200);
     
     [ModifierGroupView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
     
     [ModifierView addSubview:ModifierGroupView];
     
     CGFloat widthfield5=(ModifierGroupView.frame.size.width)/4;
     CGFloat group=(widthfield5/2)+100;
     if (isLandScope)
     {
     ModifierGroupTable = [[UITableView alloc] initWithFrame:CGRectMake(group,0,widthfield5+450, 300) style:UITableViewStylePlain];
     }
     else
     {
     ModifierGroupTable = [[UITableView alloc] initWithFrame:CGRectMake(group,0,widthfield5+300, 300) style:UITableViewStylePlain];
     }
     ModifierGroupTable.backgroundColor=[UIColor whiteColor];
     ModifierGroupTable.delegate = self;
     ModifierGroupTable.dataSource = self;
     ModifierGroupTable.scrollEnabled = YES;
     [ModifierGroupTable.layer setBorderWidth: 2.0];
     [ModifierGroupTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
     [ModifierGroupView addSubview:ModifierGroupTable];
     
     AddModifierGroupBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     [AddModifierGroupBtn setTitle:@"Add Modifier Group" forState:UIControlStateNormal];
     [AddModifierGroupBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
     
     AddModifierGroupBtn.frame=CGRectMake(40,20,widthfield5-80,80);
     [AddModifierGroupBtn addTarget:self action:@selector(infoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
     AddModifierGroupBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
     AddModifierGroupBtn.titleLabel.numberOfLines = 2;
     AddModifierGroupBtn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
     [AddModifierGroupBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     
     [ModifierGroupView addSubview:AddModifierGroupBtn];
     
     ModifierDeslbl=[[UILabel alloc] init];
     ModifierDeslbl.frame=CGRectMake(40,100,widthfield5,40);
     [ModifierDeslbl setFont:[UIFont systemFontOfSize:20.0f]];
     [ModifierDeslbl setBackgroundColor:[UIColor clearColor]];
     [ModifierDeslbl setTextColor:[UIColor whiteColor]];
     [ModifierDeslbl setText:@"Description"];
     [ModifierDeslbl setTextAlignment:NSTextAlignmentLeft];
     [ModifierGroupView addSubview:ModifierDeslbl];
     
     ModifierDesField=[[UITextField alloc] init];
     //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
     
     ModifierDesField.frame=CGRectMake(20, 140,widthfield5-40, 40);
     ModifierDesField.delegate=self;
     UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
     // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
     ModifierDesField.leftView = paddingview;
     ModifierDesField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
     ModifierDesField.leftViewMode = UITextFieldViewModeAlways;
     [ModifierDesField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
     
     [ModifierDesField addTarget:self action:@selector(GeneralinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
     [ModifierDesField setAutocorrectionType:UITextAutocorrectionTypeNo];
     
     //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
     
     [ModifierGroupView addSubview:ModifierDesField];
     
     promptlbl=[[UILabel alloc] init];
     promptlbl.frame=CGRectMake(40,180,widthfield5,40);
     [promptlbl setFont:[UIFont systemFontOfSize:20.0f]];
     [promptlbl setBackgroundColor:[UIColor clearColor]];
     [promptlbl setTextColor:[UIColor whiteColor]];
     [promptlbl setText:@"Prompt"];
     [promptlbl setTextAlignment:NSTextAlignmentLeft];
     [ModifierGroupView addSubview:promptlbl];
     
     PromptField=[[UITextField alloc] init];
     //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
     
     PromptField.frame=CGRectMake(20, 220,widthfield5-40, 40);
     PromptField.delegate=self;
     UIView *paddingview2=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
     // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
     PromptField.leftView = paddingview2;
     PromptField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
     PromptField.leftViewMode = UITextFieldViewModeAlways;
     [PromptField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
     
     [PromptField addTarget:self action:@selector(GeneralinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
     [PromptField setAutocorrectionType:UITextAutocorrectionTypeNo];
     
     //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
     
     [ModifierGroupView addSubview:PromptField];
     
     Toselectlbl=[[UILabel alloc] init];
     Toselectlbl.frame=CGRectMake(20,290,widthfield5, 40);
     
     [Toselectlbl setFont:[UIFont systemFontOfSize:20.0f]];
     [Toselectlbl setBackgroundColor:[UIColor clearColor]];
     [Toselectlbl setTextColor:[UIColor whiteColor]];
     [Toselectlbl setText:@"#To Select"];
     [Toselectlbl setTextAlignment:NSTextAlignmentLeft];
     [ModifierGroupView addSubview:Toselectlbl];
     
     ToSelectBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     ToSelectBtn.frame=CGRectMake(20,320,widthfield5, 40);
     [ToSelectBtn addTarget:self action:@selector(AddpricingClicked) forControlEvents:UIControlEventTouchUpInside];
     [ToSelectBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     [ToSelectBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
     [ModifierGroupView addSubview:ToSelectBtn];
     ToSelectTable = [[UITableView alloc] initWithFrame:CGRectMake(20,360,widthfield5, 100) style:UITableViewStylePlain];
     ToSelectTable.backgroundColor=[UIColor whiteColor];
     ToSelectTable.delegate = self;
     ToSelectTable.dataSource = self;
     ToSelectTable.hidden=YES;
     ToSelectTable.scrollEnabled = YES;
     [ToSelectTable.layer setBorderWidth: 2.0];
     [ToSelectTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
     [ModifierGroupView addSubview:ToSelectTable];
     
     ChargeforModifierBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     ChargeforModifierBtn.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10,325,30, 30);
     
     [ChargeforModifierBtn addTarget:self action:@selector(BarBtnClicked) forControlEvents:UIControlEventTouchUpInside];
     [ChargeforModifierBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     [ChargeforModifierBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
     [ChargeforModifierBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
     [ModifierGroupView addSubview:ChargeforModifierBtn];
     
     
     chargeforModifierlbl=[[UILabel alloc] init];
     chargeforModifierlbl.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10+ChargeforModifierBtn.frame.size.width+10,323,widthfield5+50, 40);
     
     [chargeforModifierlbl setFont:[UIFont systemFontOfSize:20.0f]];
     [chargeforModifierlbl setBackgroundColor:[UIColor clearColor]];
     [chargeforModifierlbl setTextColor:[UIColor whiteColor]];
     [chargeforModifierlbl setText:@"Change for modifiers"];
     [chargeforModifierlbl setTextAlignment:NSTextAlignmentLeft];
     [ModifierGroupView addSubview:chargeforModifierlbl];
     ForceBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     ForceBtn.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10+ChargeforModifierBtn.frame.size.width+10+chargeforModifierlbl.frame.size.width,325,30, 30);
     
     [ForceBtn addTarget:self action:@selector(BarBtnClicked) forControlEvents:UIControlEventTouchUpInside];
     [ForceBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     [ForceBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
     [ForceBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
     [ModifierGroupView addSubview:ForceBtn];
     
     
     Forcelbl=[[UILabel alloc] init];
     Forcelbl.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10+ChargeforModifierBtn.frame.size.width+10+chargeforModifierlbl.frame.size.width+40,323,widthfield5, 40);
     
     [Forcelbl setFont:[UIFont systemFontOfSize:20.0f]];
     [Forcelbl setBackgroundColor:[UIColor clearColor]];
     [Forcelbl setTextColor:[UIColor whiteColor]];
     [Forcelbl setText:@"Forced?"];
     [Forcelbl setTextAlignment:NSTextAlignmentLeft];
     [ModifierGroupView addSubview:Forcelbl];
     
     SaveGroupModifierBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     SaveGroupModifierBtn.frame=CGRectMake(widthfield5+60,400,80,40);
     [SaveGroupModifierBtn addTarget:self action:@selector(SaveProductData) forControlEvents:UIControlEventTouchUpInside];
     
     //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
     [SaveGroupModifierBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
     [SaveGroupModifierBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
     [ModifierGroupView addSubview:SaveGroupModifierBtn];
     
     CancelGroupModifierBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     CancelGroupModifierBtn.frame=CGRectMake(widthfield5+260,400,80,40);
     [CancelGroupModifierBtn addTarget:self action:@selector(GropumodifierCancelclicked) forControlEvents:UIControlEventTouchUpInside];
     [CancelGroupModifierBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
     [CancelGroupModifierBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
     // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
     [ModifierGroupView addSubview:CancelGroupModifierBtn];
     
     ModIndividualView=[[UIView alloc] init];
     ModIndividualView.frame=CGRectMake(0,100 , ModifierView.frame.size.width, ModifierView.frame.size.height-200);
     
     [ModIndividualView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
     
     
     
     CGFloat widthfield6=(ModIndividualView.frame.size.width)/4;
     CGFloat Ind=(widthfield6/2)+100;
     if (isLandScope)
     {
     ModifierIndividualTable = [[UITableView alloc] initWithFrame:CGRectMake(Ind,0,widthfield6+450, 350) style:UITableViewStylePlain];
     }
     else
     {
     ModifierIndividualTable = [[UITableView alloc] initWithFrame:CGRectMake(Ind,0,widthfield6+300, 350) style:UITableViewStylePlain];
     }
     ModifierIndividualTable.backgroundColor=[UIColor whiteColor];
     ModifierIndividualTable.delegate = self;
     ModifierIndividualTable.dataSource = self;
     ModifierIndividualTable.scrollEnabled = YES;
     [ModifierIndividualTable.layer setBorderWidth: 2.0];
     [ModifierIndividualTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
     [ModIndividualView addSubview:ModifierIndividualTable];
     
     
     
     AddModifierBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     [AddModifierBtn setTitle:@"Add Modifier" forState:UIControlStateNormal];
     [AddModifierBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
     
     AddModifierBtn.frame=CGRectMake(40,130,widthfield6-80,80);
     [AddModifierBtn addTarget:self action:@selector(infoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
     AddModifierBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
     AddModifierBtn.titleLabel.numberOfLines = 2;
     AddModifierBtn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
     [AddModifierBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     
     [ModIndividualView addSubview:AddModifierBtn];
     
     SaveIndividualBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     SaveIndividualBtn.frame=CGRectMake(widthfield6+60,400,80,40);
     [SaveIndividualBtn addTarget:self action:@selector(SaveProductData) forControlEvents:UIControlEventTouchUpInside];
     
     //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
     [SaveIndividualBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
     [SaveIndividualBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
     [ModIndividualView addSubview:SaveIndividualBtn];
     
     CancelIndividualBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     CancelIndividualBtn.frame=CGRectMake(widthfield6+260,400,80,40);
     [CancelIndividualBtn addTarget:self action:@selector(IndividualmodifierCancelclicked) forControlEvents:UIControlEventTouchUpInside];
     [CancelIndividualBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
     [CancelIndividualBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
     // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
     [ModIndividualView addSubview:CancelIndividualBtn];
     }
     */
    else  if (selectedButton==104){
        PriceLevelsBackView=[[UIView alloc]init];
        if (isLandScope) {
            PriceLevelsBackView.frame=CGRectMake(0, 0, 1024, 768);
        }
        
        else{
            
            PriceLevelsBackView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [PriceLevelsBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:PriceLevelsBackView];
        
        PriceLevelsView=[[UIView alloc] init];
        PriceLevelsView.frame=CGRectMake(50, 50, PriceLevelsBackView.frame.size.width-100, PriceLevelsBackView.frame.size.height-100);
        
        [PriceLevelsView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [PriceLevelsView.layer setBorderWidth:2.0];
        [PriceLevelsView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [PriceLevelsBackView addSubview:PriceLevelsView];
        
        CGFloat widthfield7=(PriceLevelsView.frame.size.width)/4;
        
        PriceLevelTextlbl=[[UILabel alloc] init];
        PriceLevelTextlbl.frame=CGRectMake(40,5,PriceLevelsView.frame.size.width-80,40);
        [PriceLevelTextlbl setFont:[UIFont systemFontOfSize:23.0f]];
        [PriceLevelTextlbl setBackgroundColor:[UIColor clearColor]];
        [PriceLevelTextlbl setTextColor:[UIColor whiteColor]];
        [PriceLevelTextlbl setText:@"Customers can automatically be charged one of 26 price levels"];
        PriceLevelTextlbl.lineBreakMode = NSLineBreakByWordWrapping;
        PriceLevelTextlbl.numberOfLines = 3;
        [PriceLevelTextlbl setTextAlignment:NSTextAlignmentLeft];
        [PriceLevelsView addSubview:PriceLevelTextlbl];
        
        
        PriceLevelsTable = [[UITableView alloc] initWithFrame:CGRectMake(10,40,PriceLevelsView.frame.size.width-20, 350) style:UITableViewStylePlain];
        
        PriceLevelsTable.backgroundColor=[UIColor whiteColor];
        PriceLevelsTable.delegate = self;
        PriceLevelsTable.dataSource = self;
        PriceLevelsTable.scrollEnabled = YES;
        [PriceLevelsTable.layer setBorderWidth: 2.0];
        [PriceLevelsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [PriceLevelsView addSubview:PriceLevelsTable];
        
        SavePriceLevelLbl = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        SavePriceLevelLbl.frame=CGRectMake(widthfield7+60,420,80,40);
        [SavePriceLevelLbl addTarget:self action:@selector(SaveProductData) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [SavePriceLevelLbl setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[SavePriceLevelLbl setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [SavePriceLevelLbl setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        [PriceLevelsView addSubview:SavePriceLevelLbl];
        
        CancelPricelevelbtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        CancelPricelevelbtn.frame=CGRectMake(widthfield7+260,420,80,40);
        [CancelPricelevelbtn addTarget:self action:@selector(IndividualmodifierCancelclicked) forControlEvents:UIControlEventTouchUpInside];
        [CancelPricelevelbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[CancelPricelevelbtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        [CancelPricelevelbtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [PriceLevelsView addSubview:CancelPricelevelbtn];
    }
    
    
}
-(void)ChangeinfoButton2Clicked:(UIButton *)sender
{
    NSInteger selectedbtn=sender.tag;
    if (selectedbtn==100){
        if (!OrderingInfoBackView)
            OrderingInfoBackView=[[UIView alloc]init];
        if (isLandScope) {
            OrderingInfoBackView.frame=CGRectMake(0, 0, 1024, 768);
        }
        
        else{
            
            OrderingInfoBackView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [OrderingInfoBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:OrderingInfoBackView];
        if (!OrderingInfoView)
            OrderingInfoView=[[UIView alloc] init];
        if (isLandScope) {
            OrderingInfoView.frame=CGRectMake(50, 50, OrderingInfoBackView.frame.size.width-100, OrderingInfoBackView.frame.size.height-100);
        }
        else
        {
            OrderingInfoView.frame=CGRectMake(50, 150, OrderingInfoBackView.frame.size.width-100, OrderingInfoBackView.frame.size.height-400);
        }
        
        [OrderingInfoView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [OrderingInfoView.layer setBorderWidth:2.0];
        [OrderingInfoView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [OrderingInfoBackView addSubview:OrderingInfoView];
        if (!OpVendorsArray)
            OpVendorsArray=[[NSMutableArray alloc]init];
        NSString *querySQL = [NSString stringWithFormat: @"SELECT vendor_company_name FROM vendor"];
        NSMutableArray *venodrsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:venodrsArray];
        for (NSDictionary *myDict in venodrsArray)
        {
            [OpVendorsArray addObject:[myDict objectForKey:@"vendor_company_name"]];
        }
        // //NSLog(@"%@",OpVendorsArray);
        
        CGFloat widthfield4=(OrderingInfoView.frame.size.width)/4;
        if (!OrderingInfotextLbl)
            OrderingInfotextLbl=[[UILabel alloc] init];
        OrderingInfotextLbl.frame=CGRectMake(widthfield4+100,10,widthfield4+100,40);
        [OrderingInfotextLbl setFont:[UIFont systemFontOfSize:25.0f]];
        [OrderingInfotextLbl setBackgroundColor:[UIColor clearColor]];
        [OrderingInfotextLbl setTextColor:[UIColor whiteColor]];
        [OrderingInfotextLbl setText:@"OrderingInfo Details"];
        [OrderingInfotextLbl setTextAlignment:NSTextAlignmentLeft];
        [OrderingInfoView addSubview:OrderingInfotextLbl];
        
        if (!Addvendorlbl)
            Addvendorlbl=[[UILabel alloc] init];
        Addvendorlbl.frame=CGRectMake(10, 125,widthfield4, 100);
        [Addvendorlbl setFont:[UIFont systemFontOfSize:20.0f]];
        [Addvendorlbl setBackgroundColor:[UIColor clearColor]];
        [Addvendorlbl setTextColor:[UIColor whiteColor]];
        
        [Addvendorlbl setText:@"Add Pricing From Vendor"];
        Addvendorlbl.lineBreakMode = NSLineBreakByWordWrapping;
        Addvendorlbl.numberOfLines = 2;
        [Addvendorlbl setTextAlignment:NSTextAlignmentLeft];
        [OrderingInfoView addSubview:Addvendorlbl];
        if (!AddOpVendorBtn)
            AddOpVendorBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        AddOpVendorBtn.frame=CGRectMake(Addvendorlbl.frame.size.width, 150,widthfield4+10, 40);
        [AddOpVendorBtn addTarget:self action:@selector(AddOpVendorClicked) forControlEvents:UIControlEventTouchUpInside];
        [AddOpVendorBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        //[AddOpVendorBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
        
        [AddOpVendorBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
        
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [OrderingInfoView addSubview:AddOpVendorBtn];
        
        if (!OpVendorslistTable)
            OpVendorslistTable = [[UITableView alloc] initWithFrame:CGRectMake(Addvendorlbl.frame.size.width, 50,widthfield4+10, 100) style:UITableViewStylePlain];
        OpVendorslistTable.backgroundColor=[UIColor whiteColor];
        OpVendorslistTable.delegate = self;
        OpVendorslistTable.dataSource = self;
        OpVendorslistTable.scrollEnabled = YES;
        OpVendorslistTable.hidden=YES;
        [OpVendorslistTable.layer setBorderWidth: 1.0];
        [OpVendorslistTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [OrderingInfoView addSubview:OpVendorslistTable];
        
        
        if (!OrderingInfoTable)
            OrderingInfoTable = [[UITableView alloc] initWithFrame:CGRectMake(10, 200,OrderingInfoView.frame.size.width-20, 300) style:UITableViewStylePlain];
        OrderingInfoTable.backgroundColor=[UIColor whiteColor];
        OrderingInfoTable.delegate = self;
        OrderingInfoTable.dataSource = self;
        OrderingInfoTable.scrollEnabled = YES;
        
        [OrderingInfoTable.layer setBorderWidth: 1.0];
        [OrderingInfoTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [OrderingInfoView addSubview:OrderingInfoTable];
        
        @autoreleasepool {
            SaveOrderingInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SaveOrderingInfoBtn.frame=CGRectMake(widthfield4+120,540,80,30);
            [SaveOrderingInfoBtn addTarget:self action:@selector(SaveorderingInfo) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SaveOrderingInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[SaveOrderingInfoBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [SaveOrderingInfoBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            [OrderingInfoView addSubview:SaveOrderingInfoBtn];
            
            CancelOrderingInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelOrderingInfoBtn.frame=CGRectMake(widthfield4+220,540,80,30);
            [CancelOrderingInfoBtn addTarget:self action:@selector(CancelOrderingInfo) forControlEvents:UIControlEventTouchUpInside];
            [CancelOrderingInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[CancelOrderingInfoBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            
            [CancelOrderingInfoBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [OrderingInfoView addSubview:CancelOrderingInfoBtn];
            
        }
        
        
    }else if (selectedbtn==101){
        if (!HistoryPopupView)
            HistoryPopupView=[[UIView alloc]init];
        if (isLandScope) {
            HistoryPopupView.frame=CGRectMake(0, 0, 1024, 768);
        }
        
        else{
            
            HistoryPopupView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [HistoryPopupView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:HistoryPopupView];
        if (!HistoryView)
            HistoryView=[[UIView alloc] init];
        if (isLandScope)
        {
            HistoryView.frame=CGRectMake(50, 100, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-200);
        }
        else
        {
            HistoryView.frame=CGRectMake(50, 150, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-400);
        }
        
        
        [HistoryView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [HistoryView.layer setBorderWidth:2.0];
        [HistoryView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [HistoryPopupView addSubview:HistoryView];
        
        
        CGFloat widthfield5=(HistoryView.frame.size.width)/4;
        if (!Historytextlbl)
            Historytextlbl=[[UILabel alloc] init];
        Historytextlbl.frame=CGRectMake(widthfield5+120,10,widthfield5,40);
        [Historytextlbl setFont:[UIFont systemFontOfSize:25.0f]];
        [Historytextlbl setBackgroundColor:[UIColor clearColor]];
        [Historytextlbl setTextColor:[UIColor whiteColor]];
        [Historytextlbl setText:@"Sales History"];
        [Historytextlbl setTextAlignment:NSTextAlignmentLeft];
        [HistoryView addSubview:Historytextlbl];
        if (!SalesHistoryTable)
            SalesHistoryTable = [[UITableView alloc] initWithFrame:CGRectMake(10,60,HistoryView.frame.size.width-20, 400) style:UITableViewStylePlain];
        SalesHistoryTable.backgroundColor=[UIColor whiteColor];
        SalesHistoryTable.delegate = self;
        SalesHistoryTable.dataSource = self;
        SalesHistoryTable.scrollEnabled = YES;
        
        [SalesHistoryTable.layer setBorderWidth: 1.0];
        [SalesHistoryTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [HistoryView addSubview:SalesHistoryTable];
        if (!saveHistoryBtn)
            saveHistoryBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        saveHistoryBtn.frame=CGRectMake(widthfield5+160,500,80,30);
        [saveHistoryBtn addTarget:self action:@selector(Savehistory) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [saveHistoryBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[saveHistoryBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [saveHistoryBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        
        [HistoryView addSubview:saveHistoryBtn];
        NSString *querySQL1 = [NSString stringWithFormat: @"SELECT item_id, discount,total_tax,item_name,item_desscription,price_you_charge,avg_cost,item_quantity,invoice_id,unique_id,created_timestamp,payment_type,in_department,in_vendor,store_id,status,employee,customer FROM invoice_items_table WHERE item_id='%@'",InvItemNumber];
        
        invoiceItemsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL1 resultsArray:invoiceItemsArray];
        
        itemIDArray=[[NSMutableArray alloc]init];
        for (NSDictionary *myDict in invoiceItemsArray)
        {
            [itemIDArray addObject:[myDict objectForKey:@"item_id"]];
        }
        SnosArray=[[NSMutableArray alloc]init];
        
        for (int i=1;i<=[itemIDArray count] ; i++)
        {
            [SnosArray  addObject:[NSString stringWithFormat:@"%d",i]];
            
        }
    }
    
    
}
-(void)DuplicateinfoButton1Clicked:(UIButton *)sender
{
    
    NSInteger selectedButton=sender.tag;
    
    if (selectedButton==100){
        SkusArray=SelectedSkusArray;
        if (!OptionalInfoBackView)
            OptionalInfoBackView=[[UIView alloc]init];
        if (isLandScope) {
            OptionalInfoBackView.frame=CGRectMake(0, 0, 1024, 768);
        }
        
        else{
            
            OptionalInfoBackView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [OptionalInfoBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:OptionalInfoBackView];
        if (!OptionalInfoView)
            OptionalInfoView=[[UIView alloc] init];
        if (isLandScope)
        {
            OptionalInfoView.frame=CGRectMake(50, 50, OptionalInfoBackView.frame.size.width-100, OptionalInfoBackView.frame.size.height-100);
        }
        else
        {
            OptionalInfoView.frame=CGRectMake(50, 150, OptionalInfoBackView.frame.size.width-100, OptionalInfoBackView.frame.size.height-400);
        }
        
        [OptionalInfoView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [OptionalInfoView.layer setBorderWidth:2.0];
        [OptionalInfoView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [OptionalInfoBackView addSubview:OptionalInfoView];
        
        CGFloat widthfield=(OptionalInfoView.frame.size.width)/4;
        CGFloat o=(widthfield/2);
        if (!OptionalinfoTextLbl)
            OptionalinfoTextLbl=[[UILabel alloc] init];
        OptionalinfoTextLbl.frame=CGRectMake(widthfield+60,10,widthfield+100, 40);
        [OptionalinfoTextLbl setFont:[UIFont systemFontOfSize:20.0f]];
        [OptionalinfoTextLbl setBackgroundColor:[UIColor clearColor]];
        [OptionalinfoTextLbl setTextColor:[UIColor whiteColor]];
        [OptionalinfoTextLbl setText:@"Optional Info Details"];
        [OptionalinfoTextLbl setTextAlignment:NSTextAlignmentLeft];
        [OptionalInfoView addSubview:OptionalinfoTextLbl];
        int w=60;
        
        for (int i=0; i<5; i++)
        {
            
            Optionalinfolbl=[[UILabel alloc] init];
            Optionalinfolbl.frame=CGRectMake(o-80, w,widthfield+10, 40);
            
            Optionalinfolbl.tag=i+100;
            [Optionalinfolbl setFont:[UIFont systemFontOfSize:20.0f]];
            [Optionalinfolbl setBackgroundColor:[UIColor clearColor]];
            [Optionalinfolbl setTextColor:[UIColor whiteColor]];
            NSArray *labelArray=[[NSArray alloc] initWithObjects:@"Bonus Points",@"Barcodes",@"Location",@"UnitSize ",@"Unit Type",nil];
            [Optionalinfolbl setText:[labelArray objectAtIndex:i]];
            [Optionalinfolbl setTextAlignment:NSTextAlignmentLeft];
            [OptionalInfoView addSubview:Optionalinfolbl];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            OptionalinfoFields=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            if (isLandScope) {
                OptionalinfoFields.frame=CGRectMake(o+Optionalinfolbl.frame.size.width-150, w,widthfield-60, 40);
            }
            else
            {
                OptionalinfoFields.frame=CGRectMake(o+Optionalinfolbl.frame.size.width-130, w,widthfield-60, 40);
                
            }
            
            OptionalinfoFields.delegate=self;
            OptionalinfoFields.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            OptionalinfoFields.leftView = paddingview;
            OptionalinfoFields.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            OptionalinfoFields.leftViewMode = UITextFieldViewModeAlways;
            //[OptionalinfoFields setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
            [OptionalinfoFields setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
            
            paddingview=nil;
            
            if (OptionalinfoFields.tag==100)
            {
                OptionalinfoFields.text=Editbonuspoint;
            }
            if (OptionalinfoFields.tag==101)
            {
                OptionalinfoFields.text=Editbarcode;
            }
            if (OptionalinfoFields.tag==102)
            {
                OptionalinfoFields.text=Editlocation;
            }
            if (OptionalinfoFields.tag==103)
            {
                OptionalinfoFields.text=Editunitsize;
            }
            if (OptionalinfoFields.tag==104)
            {
                OptionalinfoFields.text=EditUnittype;
            }
            [OptionalinfoFields addTarget:self action:@selector(EditOptionallinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
            [OptionalinfoFields setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [OptionalInfoView addSubview:OptionalinfoFields];
            
            w=w+60;
            
        }
        if (!OptCommissonlbl)
            OptCommissonlbl=[[UILabel alloc] init];
        OptCommissonlbl.frame=CGRectMake(o-80,360,widthfield+10, 40);
        [OptCommissonlbl setFont:[UIFont systemFontOfSize:20.0f]];
        [OptCommissonlbl setBackgroundColor:[UIColor clearColor]];
        [OptCommissonlbl setTextColor:[UIColor whiteColor]];
        [OptCommissonlbl setText:@"Commission"];
        [OptCommissonlbl setTextAlignment:NSTextAlignmentLeft];
        [OptionalInfoView addSubview:OptCommissonlbl];
        if (!optCommissionBtn)
            optCommissionBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        optCommissionBtn.frame=CGRectMake(widthfield-30, 360,widthfield-60, 40);
        [optCommissionBtn addTarget:self action:@selector(CommisionBtnClicked) forControlEvents:UIControlEventTouchUpInside];
        [optCommissionBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        //[optCommissionBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
        [optCommissionBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
        
        [optCommissionBtn setTitle:Editcommission forState:UIControlStateNormal];
        [OptionalInfoView addSubview:optCommissionBtn];
        if (!CommissionsTable)
            CommissionsTable = [[UITableView alloc] initWithFrame:CGRectMake(widthfield-30, 400,widthfield-60, 100) style:UITableViewStylePlain];
        CommissionsTable.backgroundColor=[UIColor whiteColor];
        CommissionsTable.delegate = self;
        CommissionsTable.dataSource = self;
        CommissionsTable.hidden=YES;
        CommissionsTable.scrollEnabled = YES;
        [CommissionsTable.layer setBorderWidth: 1.0];
        [CommissionsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [OptionalInfoView addSubview:CommissionsTable];
        if (!Alternatelbl)
            Alternatelbl=[[UILabel alloc] init];
        Alternatelbl.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width-10,60,widthfield+10, 40);
        [Alternatelbl setFont:[UIFont systemFontOfSize:20.0f]];
        [Alternatelbl setBackgroundColor:[UIColor clearColor]];
        [Alternatelbl setTextColor:[UIColor whiteColor]];
        [Alternatelbl setText:@"Alternate SKUs"];
        [Alternatelbl setTextAlignment:NSTextAlignmentLeft];
        [OptionalInfoView addSubview:Alternatelbl];
        if (!AlternateTable)
            AlternateTable = [[UITableView alloc] initWithFrame:CGRectMake(widthfield+optCommissionBtn.frame.size.width-10,95,widthfield+80, 100) style:UITableViewStylePlain];
        AlternateTable.backgroundColor=[UIColor whiteColor];
        AlternateTable.delegate = self;
        AlternateTable.dataSource = self;
        AlternateTable.scrollEnabled = YES;
        [AlternateTable.layer setBorderWidth: 1.0];
        [AlternateTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [OptionalInfoView addSubview:AlternateTable];
        
        if (!AddskuBtn)
            AddskuBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [AddskuBtn setTitle:@"Add Alternate Sku's" forState:UIControlStateNormal];
        //[AddskuBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
        [AddskuBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]] forState:UIControlStateNormal];
        
        AddskuBtn.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width+Alternatelbl.frame.size.width+80,100,widthfield-50, 80);
        [AddskuBtn addTarget:self action:@selector(AddskusClicked) forControlEvents:UIControlEventTouchUpInside];
        AddskuBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
        AddskuBtn.titleLabel.numberOfLines = 2;
        AddskuBtn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
        [AddskuBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        [OptionalInfoView addSubview:AddskuBtn];
        NSArray *labelArray;
        if (!labelArray)
            labelArray=[[NSArray alloc] initWithObjects:@"Modifier Item",@"Count This Item",@"Prompt Quantity",@"Print On Receipt",@"Foodstampable",@"Prompt price",nil];
        
        int z=210;
        for (int i=0; i<6; i++)
        {
            
            
            ItemBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            ItemBtn.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width-10,z,30, 30);
            ItemBtn.tag=i+100;
            [ItemBtn addTarget:self action:@selector(DuplicateItemBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
            [ItemBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            //[ItemBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
            // [ItemBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
            [ItemBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-off" ofType:@"png"]] forState:UIControlStateNormal];
            [ItemBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"checkbox-on" ofType:@"png"]] forState:UIControlStateSelected];
            
            [OptionalInfoView addSubview:ItemBtn];
            Itemlbl=[[UILabel alloc] init];
            if (isLandScope)
            {
                Itemlbl.frame=CGRectMake(widthfield+ItemBtn.frame.size.width+170, z-5,widthfield+10, 40);
            }
            else
            {
                Itemlbl.frame=CGRectMake(widthfield+ItemBtn.frame.size.width+120, z-5,widthfield+10, 40);
            }
            if (ItemBtn.tag==100)
            {
                
                if ([EditmodifierItem isEqualToString:@"yes"])
                {
                    ItemBtn.selected=YES;
                    EditmodifierItem=@"yes";
                }
                else
                {
                    ItemBtn.selected=NO;
                    EditmodifierItem=@"no";
                }
            }
            if (ItemBtn.tag==101)
            {
                
                if ([EditCountthisItem isEqualToString:@"yes"])
                {
                    ItemBtn.selected=YES;
                    EditCountthisItem=@"yes";
                }
                else
                {
                    ItemBtn.selected=NO;
                    EditCountthisItem=@"no";
                }
            }
            if (ItemBtn.tag==102)
            {
                
                if ([Editallowbuyback isEqualToString:@"yes"])
                {
                    ItemBtn.selected=YES;
                    Editallowbuyback=@"yes";
                }
                else
                {
                    ItemBtn.selected=NO;
                    Editallowbuyback=@"no";
                }
            }
            if (ItemBtn.tag==103)
            {
                
                if ([Editprintonreceipt isEqualToString:@"yes"])
                {
                    ItemBtn.selected=YES;
                    Editprintonreceipt=@"yes";
                }
                else
                {
                    ItemBtn.selected=NO;
                    Editprintonreceipt=@"no";
                }
            }
            if (ItemBtn.tag==104)
            {
                
                if ([Editfoodstampable isEqualToString:@"yes"])
                {
                    ItemBtn.selected=YES;
                    Editfoodstampable=@"yes";
                    
                }
                else
                {
                    ItemBtn.selected=NO;
                    Editfoodstampable=@"no";
                }
            }
            if (ItemBtn.tag==105)
            {
                
                if ([Editpromptprice isEqualToString:@"yes"])
                {
                    ItemBtn.selected=YES;
                    Editpromptprice=@"yes";
                    
                }
                else
                {
                    ItemBtn.selected=NO;
                    Editpromptprice=@"no";
                }
            }
            Itemlbl.tag=i+100;
            [Itemlbl setFont:[UIFont systemFontOfSize:20.0f]];
            [Itemlbl setBackgroundColor:[UIColor clearColor]];
            [Itemlbl setTextColor:[UIColor whiteColor]];
            
            [Itemlbl setText:[labelArray objectAtIndex:i]];
            [Itemlbl setTextAlignment:NSTextAlignmentLeft];
            [OptionalInfoView addSubview:Itemlbl];
            z=z+40;
            
        }
        
        @autoreleasepool {
            OptionalinfoSaveBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            OptionalinfoSaveBtn.frame=CGRectMake(widthfield+120,520,80,30);
            [OptionalinfoSaveBtn addTarget:self action:@selector(SaveEditOptionalInfo) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [OptionalinfoSaveBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[OptionalinfoSaveBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [OptionalinfoSaveBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            [OptionalInfoView addSubview:OptionalinfoSaveBtn];
            
            OptionalinfoCancelBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            OptionalinfoCancelBtn.frame=CGRectMake(widthfield+220,520,80,30);
            [OptionalinfoCancelBtn addTarget:self action:@selector(OptionalInfoCancelclicked) forControlEvents:UIControlEventTouchUpInside];
            [OptionalinfoCancelBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[OptionalinfoCancelBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            
            [OptionalinfoCancelBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [OptionalInfoView addSubview:OptionalinfoCancelBtn];
        }
        
    }
    /*   if (selectedButton==101)
     {
     PendingOrderBackView=[[UIView alloc]init];
     if (isLandScope) {
     PendingOrderBackView.frame=CGRectMake(0, 0, 1024, 768);
     }
     
     else{
     
     PendingOrderBackView.frame=CGRectMake(0, 0, 768, 1024);
     }
     [PendingOrderBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
     [self.view addSubview:PendingOrderBackView];
     
     PendingOrderView=[[UIView alloc] init];
     PendingOrderView.frame=CGRectMake(50, 50, PendingOrderBackView.frame.size.width-100, PendingOrderBackView.frame.size.height-100);
     
     [PendingOrderView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
     
     [PendingOrderBackView addSubview:PendingOrderView];
     
     
     CGFloat widthfield2=(PendingOrderView.frame.size.width)/4;
     CGFloat pen=(widthfield2/2);
     PendingOrderTextlbl=[[UILabel alloc] init];
     PendingOrderTextlbl.frame=CGRectMake(widthfield2+60,10,widthfield2+200, 40);
     [PendingOrderTextlbl setFont:[UIFont systemFontOfSize:22.0f]];
     [PendingOrderTextlbl setBackgroundColor:[UIColor clearColor]];
     [PendingOrderTextlbl setTextColor:[UIColor whiteColor]];
     [PendingOrderTextlbl setText:@"Pending Order Details"];
     [PendingOrderTextlbl setTextAlignment:NSTextAlignmentLeft];
     [PendingOrderView addSubview:PendingOrderTextlbl];
     OpenRadioBtn = [[UIButton alloc] init];
     OpenRadioBtn.frame=CGRectMake(pen-60, 60, 25, 25);
     [OpenRadioBtn setTag:0];
     [OpenRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
     [OpenRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
     
     [OpenRadioBtn addTarget:self action:@selector(OpenRadioBtnClciked) forControlEvents:UIControlEventTouchUpInside];
     [PendingOrderView addSubview:OpenRadioBtn];
     openlbl=[[UILabel alloc] init];
     openlbl.frame=CGRectMake(pen-60+OpenRadioBtn.frame.size.width+5,55,widthfield2,40);
     [openlbl setFont:[UIFont systemFontOfSize:20.0f]];
     [openlbl setBackgroundColor:[UIColor clearColor]];
     [openlbl setTextColor:[UIColor whiteColor]];
     [openlbl setText:@"Open"];
     OpenRadioBtn.selected=YES;
     [openlbl setTextAlignment:NSTextAlignmentLeft];
     [PendingOrderView addSubview:openlbl];
     
     
     CompleteRadioBtn = [[UIButton alloc] init];
     CompleteRadioBtn.frame=CGRectMake(pen-60+openlbl.frame.size.width, 60, 25, 25);
     [CompleteRadioBtn setTag:1];
     [CompleteRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
     [CompleteRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
     [CompleteRadioBtn addTarget:self action:@selector(CompleteRadioBtnClicked) forControlEvents:UIControlEventTouchUpInside];
     [PendingOrderView addSubview:CompleteRadioBtn];
     
     completelbl=[[UILabel alloc] init];
     completelbl.frame=CGRectMake(pen-35+openlbl.frame.size.width,55,widthfield2,40);
     [completelbl setFont:[UIFont systemFontOfSize:20.0f]];
     [completelbl setBackgroundColor:[UIColor clearColor]];
     [completelbl setTextColor:[UIColor whiteColor]];
     [completelbl setText:@"Complete"];
     [completelbl setTextAlignment:NSTextAlignmentLeft];
     [PendingOrderView addSubview:completelbl];
     
     CancelRadioBtn = [[UIButton alloc] init];
     CancelRadioBtn.frame=CGRectMake(pen-60+openlbl.frame.size.width+completelbl.frame.size.width+20, 60, 25, 25);
     [CancelRadioBtn setTag:2];
     [CancelRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
     [CancelRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
     [CancelRadioBtn addTarget:self action:@selector(CancelRadioBtnClicked) forControlEvents:UIControlEventTouchUpInside];
     [PendingOrderView addSubview:CancelRadioBtn];
     
     cancellbl=[[UILabel alloc] init];
     cancellbl.frame=CGRectMake(pen-35+openlbl.frame.size.width+completelbl.frame.size.width+20,55,widthfield2,40);
     [cancellbl setFont:[UIFont systemFontOfSize:20.0f]];
     [cancellbl setBackgroundColor:[UIColor clearColor]];
     [cancellbl setTextColor:[UIColor whiteColor]];
     [cancellbl setText:@"Cancel"];
     [cancellbl setTextAlignment:NSTextAlignmentLeft];
     [PendingOrderView addSubview:cancellbl];
     
     PendingOrdersTable = [[UITableView alloc] initWithFrame:CGRectMake(pen-60,95,widthfield2+450, 400) style:UITableViewStylePlain];
     PendingOrdersTable.backgroundColor=[UIColor whiteColor];
     PendingOrdersTable.delegate = self;
     PendingOrdersTable.dataSource = self;
     PendingOrdersTable.scrollEnabled = YES;
     [PendingOrdersTable.layer setBorderWidth: 2.0];
     [PendingOrdersTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
     [PendingOrderView addSubview:PendingOrdersTable];
     
     //        CompletethisorderBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     //
     //        [CompletethisorderBtn setTitle:@"Complete This Order" forState:UIControlStateNormal];
     //        [CompletethisorderBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
     //        CompletethisorderBtn.frame=CGRectMake(PendingOrdersTable.frame.size.width+60,170,100, 100);
     //        [CompletethisorderBtn addTarget:self action:@selector(infoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
     //          CompletethisorderBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
     //        CompletethisorderBtn.titleLabel.numberOfLines = 2;
     //        CompletethisorderBtn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
     //        [CompletethisorderBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     //
     //        [PendingOrderView addSubview:CompletethisorderBtn];
     //        cancelthisOrderBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     //
     //        [cancelthisOrderBtn setTitle:@"Cancel This Order" forState:UIControlStateNormal];
     //        [cancelthisOrderBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
     //        cancelthisOrderBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
     //        cancelthisOrderBtn.frame=CGRectMake(PendingOrdersTable.frame.size.width+60,340,100, 100);
     //        [cancelthisOrderBtn addTarget:self action:@selector(infoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
     //        cancelthisOrderBtn.titleLabel.numberOfLines = 2;
     //        cancelthisOrderBtn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
     //        [cancelthisOrderBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     //
     //        [PendingOrderView addSubview:cancelthisOrderBtn];
     
     SavePendingorderBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     SavePendingorderBtn.frame=CGRectMake(widthfield2+40,520,80,40);
     [SavePendingorderBtn addTarget:self action:@selector(SaveProductData) forControlEvents:UIControlEventTouchUpInside];
     
     //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
     [SavePendingorderBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
     [SavePendingorderBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
     [PendingOrderView addSubview:SavePendingorderBtn];
     
     CancelPendingorderBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     CancelPendingorderBtn.frame=CGRectMake(widthfield2+240,520,80,40);
     [CancelPendingorderBtn addTarget:self action:@selector(PendingInfoCancelclicked) forControlEvents:UIControlEventTouchUpInside];
     [CancelPendingorderBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
     [CancelPendingorderBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
     // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
     [PendingOrderView addSubview:CancelPendingorderBtn];
     
     }*/
    else if (selectedButton==101){
        if (!NotesBackView)
            NotesBackView=[[UIView alloc]init];
        if (isLandScope) {
            NotesBackView.frame=CGRectMake(0, 0, 1024, 768);
        }
        
        else{
            
            NotesBackView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [NotesBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:NotesBackView];
        if (!NotesView)
            NotesView=[[UIView alloc] init];
        if (isLandScope)
        {
            NotesView.frame=CGRectMake(50, 50, NotesBackView.frame.size.width-100, NotesBackView.frame.size.height-100);
        }
        else
        {
            NotesView.frame=CGRectMake(50, 150, NotesBackView.frame.size.width-100, NotesBackView.frame.size.height-400);
        }
        
        [NotesView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [NotesView.layer setBorderWidth:2.0];
        [NotesView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [NotesBackView addSubview:NotesView];
        
        CGFloat widthfield3=(NotesView.frame.size.width)/4;
        if (!Notestextlbl)
            Notestextlbl=[[UILabel alloc] init];
        Notestextlbl.frame=CGRectMake(10,10,NotesView.frame.size.width-50,140);
        [Notestextlbl setFont:[UIFont systemFontOfSize:20.0f]];
        [Notestextlbl setBackgroundColor:[UIColor clearColor]];
        [Notestextlbl setTextColor:[UIColor whiteColor]];
        [Notestextlbl setText:@"You can enter notes to describe your item.This can be used to describe instructions to care for a plant,ingredients inside a meal,or other useful information."];
        Notestextlbl.lineBreakMode = NSLineBreakByWordWrapping;
        Notestextlbl.numberOfLines = 3;
        [Notestextlbl setTextAlignment:NSTextAlignmentLeft];
        [NotesView addSubview:Notestextlbl];
        if (!NotesTextView)
            NotesTextView=[[UITextView alloc] init];
        NotesTextView.frame=CGRectMake(10, 115,NotesView.frame.size.width-20,400);
        NotesTextView.delegate=self;
        NotesTextView.text=EditProductNotes;
        NotesTextView.font=[UIFont systemFontOfSize:14.0f];
        [NotesTextView setAutocorrectionType:UITextAutocorrectionTypeNo];
        NotesTextView.layer.cornerRadius=8;
        [NotesView addSubview:NotesTextView];
        
        @autoreleasepool {
            SaveNotesBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SaveNotesBtn.frame=CGRectMake(widthfield3+120,540,80,30);
            [SaveNotesBtn addTarget:self action:@selector(SaveDuplicateProductNotes) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SaveNotesBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[SaveNotesBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [SaveNotesBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            [NotesView addSubview:SaveNotesBtn];
            
            CancelNotesBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelNotesBtn.frame=CGRectMake(widthfield3+220,540,80,30);
            [CancelNotesBtn addTarget:self action:@selector(NotesCancelclicked) forControlEvents:UIControlEventTouchUpInside];
            [CancelNotesBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[CancelNotesBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            
            [CancelNotesBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [NotesView addSubview:CancelNotesBtn];
            
        }
        
    }else if (selectedButton==102){
        
          modifierNamesArray=SelectedNamesArray;
        ModifierItemNosArray=selectedModifiers;
        if (!modBackView)
            modBackView=[[UIView alloc]init];
        if (isLandScope) {
            modBackView.frame=CGRectMake(0, 0, 1024, 768);
        }
        
        else{
            
            modBackView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [modBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:modBackView];
        if (!modView)
            modView=[[UIView alloc] init];
        if (isLandScope)
        {
            modView.frame=CGRectMake(50, 50, modBackView.frame.size.width-100, modBackView.frame.size.height-100);
        }
        else
        {
            modView.frame=CGRectMake(50, 150, modBackView.frame.size.width-100, modBackView.frame.size.height-400);
        }
        [modView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [modView.layer setBorderWidth:2.0];
        [modView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [modBackView addSubview:modView];
        
        CGFloat Modwidthfield=(modView.frame.size.width)/2;
        if (!modTextlbl)
            modTextlbl=[[UILabel alloc] init];
        modTextlbl.frame=CGRectMake(Modwidthfield-100,5,Modwidthfield+200, 40);
        [modTextlbl setFont:[UIFont systemFontOfSize:22.0f]];
        [modTextlbl setBackgroundColor:[UIColor clearColor]];
        [modTextlbl setTextColor:[UIColor whiteColor]];
        [modTextlbl setText:@"Modifier List"];
        [modTextlbl setTextAlignment:NSTextAlignmentLeft];
        [modView addSubview:modTextlbl];
       
            ItemNumbersArray=[[NSMutableArray alloc]init];
            itemsListArray=[[NSMutableArray alloc]init];
            
            ItemnameArray=[[NSMutableArray alloc]init];
            NamesArray=[[NSMutableArray alloc]init];
            modifierItemsArray=[[NSMutableArray alloc]init];
        
        NSString *querySQL = [NSString stringWithFormat: @"SELECT inventary_modifier_item,inventory_item_no FROM optional_info_table"];
        NSMutableArray *optinfoArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:optinfoArray];
        
        
        NSString *prodquerySQL = [NSString stringWithFormat: @"SELECT inventary_item_name FROM inventorytable"];
        NSMutableArray *productArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:prodquerySQL resultsArray:productArray];
        if ([optinfoArray count]>0)
        {
            for (NSDictionary *myDict in optinfoArray)
            {
                
                [modifierItemsArray addObject:[myDict objectForKey:@"inventary_modifier_item"]];
                
                [ItemNumbersArray addObject:[myDict objectForKey:@"inventory_item_no"]];
                
                
            }
            for (NSDictionary *myDict in productArray)
            {
                [ItemnameArray addObject:[myDict objectForKey:@"inventary_item_name"]];
            }
            
            
            for (int i=0; i<[modifierItemsArray count]; i++)
            {
                NSString *mystr=[modifierItemsArray objectAtIndex:i];
                if ([mystr isEqualToString:@"yes"])
                {
                    NSString *item=[ItemNumbersArray objectAtIndex:i];
                    NSString *name=[ItemnameArray objectAtIndex:i];
                    [NamesArray addObject:name];
                    
                    [itemsListArray addObject:item];
                    item=name=nil;
                }
                mystr=nil;
            }
        }
        
        // //NSLog(@"%@",itemsListArray);
        if (!ModifieritemsDropdownBtn)
            ModifieritemsDropdownBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        ModifieritemsDropdownBtn.frame=CGRectMake(20, 50,Modwidthfield-150, 40);
        [ModifieritemsDropdownBtn addTarget:self action:@selector(ModifierItemClicked) forControlEvents:UIControlEventTouchUpInside];
        
        [ModifieritemsDropdownBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        //[ModifieritemsDropdownBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
        [ModifieritemsDropdownBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
        [modView addSubview:ModifieritemsDropdownBtn];
        if (!ItemsListTable)
            ItemsListTable = [[UITableView alloc] initWithFrame:CGRectMake(20, 90,Modwidthfield-150, 200) style:UITableViewStylePlain];
        ItemsListTable.backgroundColor=[UIColor whiteColor];
        ItemsListTable.delegate = self;
        ItemsListTable.dataSource = self;
        ItemsListTable.hidden=YES;
        ItemsListTable.scrollEnabled = YES;
        [ItemsListTable.layer setBorderWidth: 1.0];
        [ItemsListTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [modView addSubview:ItemsListTable];
        [ItemsListTable reloadData];
        
        if (!modifierItemsTable)
            modifierItemsTable = [[UITableView alloc] initWithFrame:CGRectMake(20+ModifieritemsDropdownBtn.frame.size.width+10, 40,modView.frame.size.width-(20+ModifieritemsDropdownBtn.frame.size.width+20), 400) style:UITableViewStylePlain];
        modifierItemsTable.backgroundColor=[UIColor whiteColor];
        modifierItemsTable.delegate = self;
        modifierItemsTable.dataSource = self;
        // modifierItemsTable.hidden=YES;
        modifierItemsTable.scrollEnabled = YES;
        [modifierItemsTable.layer setBorderWidth: 1.0];
        [modifierItemsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [modView addSubview:modifierItemsTable];
        [modifierItemsTable reloadData];
        @autoreleasepool {
            SavemodBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SavemodBtn.frame=CGRectMake(Modwidthfield-100,460,80,30);
            [SavemodBtn addTarget:self action:@selector(SaveModifierData) forControlEvents:UIControlEventTouchUpInside];
            [SavemodBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[SavemodBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [SavemodBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            [modView addSubview:SavemodBtn];
            
            CancelModBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelModBtn.frame=CGRectMake(Modwidthfield+30,460,80,30);
            [CancelModBtn addTarget:self action:@selector(ModifierCancelClicked) forControlEvents:UIControlEventTouchUpInside];
            [CancelModBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[CancelModBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            [CancelModBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [modView addSubview:CancelModBtn];
        }
        
        
    }
    
    /*  if (selectedButton==102)
     {
     ModifierBackView=[[UIView alloc]init];
     if (isLandScope) {
     ModifierBackView.frame=CGRectMake(0, 0, 1024, 768);
     }
     
     else{
     
     ModifierBackView.frame=CGRectMake(0, 0, 768, 1024);
     }
     [ModifierBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
     [self.view addSubview:ModifierBackView];
     
     ModifierView=[[UIView alloc] init];
     ModifierView.frame=CGRectMake(50, 50, ModifierBackView.frame.size.width-100, ModifierBackView.frame.size.height-100);
     
     [ModifierView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
     
     [ModifierBackView addSubview:ModifierView];
     
     CGFloat widthfield4=(ModifierView.frame.size.width)/4;
     CGFloat mod=(widthfield4/2)+100;
     ModifierTextlbl=[[UILabel alloc] init];
     ModifierTextlbl.frame=CGRectMake(widthfield4+60,10,widthfield4+200, 40);
     [ModifierTextlbl setFont:[UIFont systemFontOfSize:22.0f]];
     [ModifierTextlbl setBackgroundColor:[UIColor clearColor]];
     [ModifierTextlbl setTextColor:[UIColor whiteColor]];
     [ModifierTextlbl setText:@"Modifier List"];
     [ModifierTextlbl setTextAlignment:NSTextAlignmentLeft];
     [ModifierView addSubview:ModifierTextlbl];
     
     GroupRadioBtn = [[UIButton alloc] init];
     GroupRadioBtn.frame=CGRectMake(mod, 60, 25, 25);
     [GroupRadioBtn setTag:1];
     [GroupRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
     [GroupRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
     [GroupRadioBtn addTarget:self action:@selector(GroupRadioBtnClicked) forControlEvents:UIControlEventTouchUpInside];
     GroupRadioBtn.selected=YES;
     [ModifierView addSubview:GroupRadioBtn];
     
     Grouplbl=[[UILabel alloc] init];
     Grouplbl.frame=CGRectMake(mod+GroupRadioBtn.frame.size.width+5,55,100,40);
     [Grouplbl setFont:[UIFont systemFontOfSize:20.0f]];
     [Grouplbl setBackgroundColor:[UIColor clearColor]];
     [Grouplbl setTextColor:[UIColor whiteColor]];
     [Grouplbl setText:@"Group"];
     [Grouplbl setTextAlignment:NSTextAlignmentLeft];
     [ModifierView addSubview:Grouplbl];
     
     IndividualRadioBtn = [[UIButton alloc] init];
     IndividualRadioBtn.frame=CGRectMake(mod+GroupRadioBtn.frame.size.width+Grouplbl.frame.size.width+20, 60, 25, 25);
     [IndividualRadioBtn setTag:1];
     [IndividualRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
     [IndividualRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
     [IndividualRadioBtn addTarget:self action:@selector(IndividualRadioBtnClicked) forControlEvents:UIControlEventTouchUpInside];
     [ModifierView addSubview:IndividualRadioBtn];
     individuallbl=[[UILabel alloc] init];
     individuallbl.frame=CGRectMake(mod+GroupRadioBtn.frame.size.width+Grouplbl.frame.size.width+50,55,200,40);
     [individuallbl setFont:[UIFont systemFontOfSize:20.0f]];
     [individuallbl setBackgroundColor:[UIColor clearColor]];
     [individuallbl setTextColor:[UIColor whiteColor]];
     [individuallbl setText:@"Individual Items"];
     [individuallbl setTextAlignment:NSTextAlignmentLeft];
     [ModifierView addSubview:individuallbl];
     
     ModifierGroupView=[[UIView alloc] init];
     ModifierGroupView.frame=CGRectMake(0,100 , ModifierView.frame.size.width, ModifierView.frame.size.height-200);
     
     [ModifierGroupView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
     
     [ModifierView addSubview:ModifierGroupView];
     
     CGFloat widthfield5=(ModifierGroupView.frame.size.width)/4;
     CGFloat group=(widthfield5/2)+100;
     if (isLandScope)
     {
     ModifierGroupTable = [[UITableView alloc] initWithFrame:CGRectMake(group,0,widthfield5+450, 300) style:UITableViewStylePlain];
     }
     else
     {
     ModifierGroupTable = [[UITableView alloc] initWithFrame:CGRectMake(group,0,widthfield5+300, 300) style:UITableViewStylePlain];
     }
     ModifierGroupTable.backgroundColor=[UIColor whiteColor];
     ModifierGroupTable.delegate = self;
     ModifierGroupTable.dataSource = self;
     ModifierGroupTable.scrollEnabled = YES;
     [ModifierGroupTable.layer setBorderWidth: 2.0];
     [ModifierGroupTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
     [ModifierGroupView addSubview:ModifierGroupTable];
     
     AddModifierGroupBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     [AddModifierGroupBtn setTitle:@"Add Modifier Group" forState:UIControlStateNormal];
     [AddModifierGroupBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
     
     AddModifierGroupBtn.frame=CGRectMake(40,20,widthfield5-80,80);
     [AddModifierGroupBtn addTarget:self action:@selector(infoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
     AddModifierGroupBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
     AddModifierGroupBtn.titleLabel.numberOfLines = 2;
     AddModifierGroupBtn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
     [AddModifierGroupBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     
     [ModifierGroupView addSubview:AddModifierGroupBtn];
     
     ModifierDeslbl=[[UILabel alloc] init];
     ModifierDeslbl.frame=CGRectMake(40,100,widthfield5,40);
     [ModifierDeslbl setFont:[UIFont systemFontOfSize:20.0f]];
     [ModifierDeslbl setBackgroundColor:[UIColor clearColor]];
     [ModifierDeslbl setTextColor:[UIColor whiteColor]];
     [ModifierDeslbl setText:@"Description"];
     [ModifierDeslbl setTextAlignment:NSTextAlignmentLeft];
     [ModifierGroupView addSubview:ModifierDeslbl];
     
     ModifierDesField=[[UITextField alloc] init];
     //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
     
     ModifierDesField.frame=CGRectMake(20, 140,widthfield5-40, 40);
     ModifierDesField.delegate=self;
     UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
     // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
     ModifierDesField.leftView = paddingview;
     ModifierDesField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
     ModifierDesField.leftViewMode = UITextFieldViewModeAlways;
     [ModifierDesField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
     
     [ModifierDesField addTarget:self action:@selector(GeneralinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
     [ModifierDesField setAutocorrectionType:UITextAutocorrectionTypeNo];
     
     //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
     
     [ModifierGroupView addSubview:ModifierDesField];
     
     promptlbl=[[UILabel alloc] init];
     promptlbl.frame=CGRectMake(40,180,widthfield5,40);
     [promptlbl setFont:[UIFont systemFontOfSize:20.0f]];
     [promptlbl setBackgroundColor:[UIColor clearColor]];
     [promptlbl setTextColor:[UIColor whiteColor]];
     [promptlbl setText:@"Prompt"];
     [promptlbl setTextAlignment:NSTextAlignmentLeft];
     [ModifierGroupView addSubview:promptlbl];
     
     PromptField=[[UITextField alloc] init];
     //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
     
     PromptField.frame=CGRectMake(20, 220,widthfield5-40, 40);
     PromptField.delegate=self;
     UIView *paddingview2=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
     // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
     PromptField.leftView = paddingview2;
     PromptField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
     PromptField.leftViewMode = UITextFieldViewModeAlways;
     [PromptField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
     
     [PromptField addTarget:self action:@selector(GeneralinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
     [PromptField setAutocorrectionType:UITextAutocorrectionTypeNo];
     
     //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
     
     [ModifierGroupView addSubview:PromptField];
     
     Toselectlbl=[[UILabel alloc] init];
     Toselectlbl.frame=CGRectMake(20,290,widthfield5, 40);
     
     [Toselectlbl setFont:[UIFont systemFontOfSize:20.0f]];
     [Toselectlbl setBackgroundColor:[UIColor clearColor]];
     [Toselectlbl setTextColor:[UIColor whiteColor]];
     [Toselectlbl setText:@"#To Select"];
     [Toselectlbl setTextAlignment:NSTextAlignmentLeft];
     [ModifierGroupView addSubview:Toselectlbl];
     
     ToSelectBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     ToSelectBtn.frame=CGRectMake(20,320,widthfield5, 40);
     [ToSelectBtn addTarget:self action:@selector(AddpricingClicked) forControlEvents:UIControlEventTouchUpInside];
     [ToSelectBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     [ToSelectBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
     [ModifierGroupView addSubview:ToSelectBtn];
     ToSelectTable = [[UITableView alloc] initWithFrame:CGRectMake(20,360,widthfield5, 100) style:UITableViewStylePlain];
     ToSelectTable.backgroundColor=[UIColor whiteColor];
     ToSelectTable.delegate = self;
     ToSelectTable.dataSource = self;
     ToSelectTable.hidden=YES;
     ToSelectTable.scrollEnabled = YES;
     [ToSelectTable.layer setBorderWidth: 2.0];
     [ToSelectTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
     [ModifierGroupView addSubview:ToSelectTable];
     
     ChargeforModifierBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     ChargeforModifierBtn.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10,325,30, 30);
     
     [ChargeforModifierBtn addTarget:self action:@selector(BarBtnClicked) forControlEvents:UIControlEventTouchUpInside];
     [ChargeforModifierBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     [ChargeforModifierBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
     [ChargeforModifierBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
     [ModifierGroupView addSubview:ChargeforModifierBtn];
     
     
     chargeforModifierlbl=[[UILabel alloc] init];
     chargeforModifierlbl.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10+ChargeforModifierBtn.frame.size.width+10,323,widthfield5+50, 40);
     
     [chargeforModifierlbl setFont:[UIFont systemFontOfSize:20.0f]];
     [chargeforModifierlbl setBackgroundColor:[UIColor clearColor]];
     [chargeforModifierlbl setTextColor:[UIColor whiteColor]];
     [chargeforModifierlbl setText:@"Change for modifiers"];
     [chargeforModifierlbl setTextAlignment:NSTextAlignmentLeft];
     [ModifierGroupView addSubview:chargeforModifierlbl];
     ForceBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     ForceBtn.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10+ChargeforModifierBtn.frame.size.width+10+chargeforModifierlbl.frame.size.width,325,30, 30);
     
     [ForceBtn addTarget:self action:@selector(BarBtnClicked) forControlEvents:UIControlEventTouchUpInside];
     [ForceBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     [ForceBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-off.png"] forState:UIControlStateNormal];
     [ForceBtn setBackgroundImage:[UIImage imageNamed:@"checkbox-on.png"] forState:UIControlStateSelected];
     [ModifierGroupView addSubview:ForceBtn];
     
     
     Forcelbl=[[UILabel alloc] init];
     Forcelbl.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10+ChargeforModifierBtn.frame.size.width+10+chargeforModifierlbl.frame.size.width+40,323,widthfield5, 40);
     
     [Forcelbl setFont:[UIFont systemFontOfSize:20.0f]];
     [Forcelbl setBackgroundColor:[UIColor clearColor]];
     [Forcelbl setTextColor:[UIColor whiteColor]];
     [Forcelbl setText:@"Forced?"];
     [Forcelbl setTextAlignment:NSTextAlignmentLeft];
     [ModifierGroupView addSubview:Forcelbl];
     
     SaveGroupModifierBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     SaveGroupModifierBtn.frame=CGRectMake(widthfield5+60,400,80,40);
     [SaveGroupModifierBtn addTarget:self action:@selector(SaveProductData) forControlEvents:UIControlEventTouchUpInside];
     
     //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
     [SaveGroupModifierBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
     [SaveGroupModifierBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
     [ModifierGroupView addSubview:SaveGroupModifierBtn];
     
     CancelGroupModifierBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     CancelGroupModifierBtn.frame=CGRectMake(widthfield5+260,400,80,40);
     [CancelGroupModifierBtn addTarget:self action:@selector(GropumodifierCancelclicked) forControlEvents:UIControlEventTouchUpInside];
     [CancelGroupModifierBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
     [CancelGroupModifierBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
     // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
     [ModifierGroupView addSubview:CancelGroupModifierBtn];
     
     ModIndividualView=[[UIView alloc] init];
     ModIndividualView.frame=CGRectMake(0,100 , ModifierView.frame.size.width, ModifierView.frame.size.height-200);
     
     [ModIndividualView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
     
     
     
     CGFloat widthfield6=(ModIndividualView.frame.size.width)/4;
     CGFloat Ind=(widthfield6/2)+100;
     if (isLandScope)
     {
     ModifierIndividualTable = [[UITableView alloc] initWithFrame:CGRectMake(Ind,0,widthfield6+450, 350) style:UITableViewStylePlain];
     }
     else
     {
     ModifierIndividualTable = [[UITableView alloc] initWithFrame:CGRectMake(Ind,0,widthfield6+300, 350) style:UITableViewStylePlain];
     }
     ModifierIndividualTable.backgroundColor=[UIColor whiteColor];
     ModifierIndividualTable.delegate = self;
     ModifierIndividualTable.dataSource = self;
     ModifierIndividualTable.scrollEnabled = YES;
     [ModifierIndividualTable.layer setBorderWidth: 2.0];
     [ModifierIndividualTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
     [ModIndividualView addSubview:ModifierIndividualTable];
     
     
     
     AddModifierBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     [AddModifierBtn setTitle:@"Add Modifier" forState:UIControlStateNormal];
     [AddModifierBtn setBackgroundImage:[UIImage imageNamed:@"addinputtextfield.png"] forState:UIControlStateNormal];
     
     AddModifierBtn.frame=CGRectMake(40,130,widthfield6-80,80);
     [AddModifierBtn addTarget:self action:@selector(infoButton2Clicked:) forControlEvents:UIControlEventTouchUpInside];
     AddModifierBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
     AddModifierBtn.titleLabel.numberOfLines = 2;
     AddModifierBtn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
     [AddModifierBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
     
     [ModIndividualView addSubview:AddModifierBtn];
     
     SaveIndividualBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     SaveIndividualBtn.frame=CGRectMake(widthfield6+60,400,80,40);
     [SaveIndividualBtn addTarget:self action:@selector(SaveProductData) forControlEvents:UIControlEventTouchUpInside];
     
     //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
     [SaveIndividualBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
     [SaveIndividualBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
     [ModIndividualView addSubview:SaveIndividualBtn];
     
     CancelIndividualBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     
     CancelIndividualBtn.frame=CGRectMake(widthfield6+260,400,80,40);
     [CancelIndividualBtn addTarget:self action:@selector(IndividualmodifierCancelclicked) forControlEvents:UIControlEventTouchUpInside];
     [CancelIndividualBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
     [CancelIndividualBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
     // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
     [ModIndividualView addSubview:CancelIndividualBtn];
     }*/
    if (selectedButton==104)
    {
        PriceLevelsBackView=[[UIView alloc]init];
        if (isLandScope) {
            PriceLevelsBackView.frame=CGRectMake(0, 0, 1024, 768);
        }
        
        else{
            
            PriceLevelsBackView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [PriceLevelsBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:PriceLevelsBackView];
        
        PriceLevelsView=[[UIView alloc] init];
        PriceLevelsView.frame=CGRectMake(50, 50, PriceLevelsBackView.frame.size.width-100, PriceLevelsBackView.frame.size.height-100);
        
        [PriceLevelsView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [PriceLevelsView.layer setBorderWidth:2.0];
        [PriceLevelsView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [PriceLevelsBackView addSubview:PriceLevelsView];
        
        CGFloat widthfield7=(PriceLevelsView.frame.size.width)/4;
        
        PriceLevelTextlbl=[[UILabel alloc] init];
        PriceLevelTextlbl.frame=CGRectMake(40,5,PriceLevelsView.frame.size.width-80,40);
        [PriceLevelTextlbl setFont:[UIFont systemFontOfSize:23.0f]];
        [PriceLevelTextlbl setBackgroundColor:[UIColor clearColor]];
        [PriceLevelTextlbl setTextColor:[UIColor whiteColor]];
        [PriceLevelTextlbl setText:@"Customers can automatically be charged one of 26 price levels"];
        PriceLevelTextlbl.lineBreakMode = NSLineBreakByWordWrapping;
        PriceLevelTextlbl.numberOfLines = 3;
        [PriceLevelTextlbl setTextAlignment:NSTextAlignmentLeft];
        [PriceLevelsView addSubview:PriceLevelTextlbl];
        
        
        PriceLevelsTable = [[UITableView alloc] initWithFrame:CGRectMake(10,40,PriceLevelsView.frame.size.width-20, 350) style:UITableViewStylePlain];
        
        PriceLevelsTable.backgroundColor=[UIColor whiteColor];
        PriceLevelsTable.delegate = self;
        PriceLevelsTable.dataSource = self;
        PriceLevelsTable.scrollEnabled = YES;
        [PriceLevelsTable.layer setBorderWidth: 2.0];
        [PriceLevelsTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [PriceLevelsView addSubview:PriceLevelsTable];
        
        SavePriceLevelLbl = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        SavePriceLevelLbl.frame=CGRectMake(widthfield7+120,420,80,30);
        [SavePriceLevelLbl addTarget:self action:@selector(SaveProductData) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [SavePriceLevelLbl setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[SavePriceLevelLbl setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [SavePriceLevelLbl setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        [PriceLevelsView addSubview:SavePriceLevelLbl];
        
        CancelPricelevelbtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        CancelPricelevelbtn.frame=CGRectMake(widthfield7+220,420,80,30);
        [CancelPricelevelbtn addTarget:self action:@selector(IndividualmodifierCancelclicked) forControlEvents:UIControlEventTouchUpInside];
        [CancelPricelevelbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[CancelPricelevelbtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        [CancelPricelevelbtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [PriceLevelsView addSubview:CancelPricelevelbtn];
    }
    
    
    
    
}
-(void)DuplicateinfoButton2Clicked:(UIButton *)sender
{
    NSInteger selectedbtn=sender.tag;
    if (selectedbtn==100){
        if (!OrderingInfoBackView)
            OrderingInfoBackView=[[UIView alloc]init];
        if (isLandScope) {
            OrderingInfoBackView.frame=CGRectMake(0, 0, 1024, 768);
        }
        
        else{
            
            OrderingInfoBackView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [OrderingInfoBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:OrderingInfoBackView];
        if (!OrderingInfoView)
            OrderingInfoView=[[UIView alloc] init];
        if (isLandScope) {
            OrderingInfoView.frame=CGRectMake(50, 50, OrderingInfoBackView.frame.size.width-100, OrderingInfoBackView.frame.size.height-100);
        }
        else
        {
            OrderingInfoView.frame=CGRectMake(50, 150, OrderingInfoBackView.frame.size.width-100, OrderingInfoBackView.frame.size.height-400);
        }
        
        [OrderingInfoView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [OrderingInfoView.layer setBorderWidth:2.0];
        [OrderingInfoView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [OrderingInfoBackView addSubview:OrderingInfoView];
        if (!OpVendorsArray)
            OpVendorsArray=[[NSMutableArray alloc]init];
        NSString *querySQL = [NSString stringWithFormat: @"SELECT vendor_company_name FROM vendor"];
        NSMutableArray *venodrsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:venodrsArray];
        for (NSDictionary *myDict in venodrsArray)
        {
            [OpVendorsArray addObject:[myDict objectForKey:@"vendor_company_name"]];
        }
        // //NSLog(@"%@",OpVendorsArray);
        
        CGFloat widthfield4=(OrderingInfoView.frame.size.width)/4;
        if (!OrderingInfotextLbl)
            OrderingInfotextLbl=[[UILabel alloc] init];
        OrderingInfotextLbl.frame=CGRectMake(widthfield4+100,10,widthfield4+100,40);
        [OrderingInfotextLbl setFont:[UIFont systemFontOfSize:25.0f]];
        [OrderingInfotextLbl setBackgroundColor:[UIColor clearColor]];
        [OrderingInfotextLbl setTextColor:[UIColor whiteColor]];
        [OrderingInfotextLbl setText:@"OrderingInfo Details"];
        [OrderingInfotextLbl setTextAlignment:NSTextAlignmentLeft];
        [OrderingInfoView addSubview:OrderingInfotextLbl];
        
        if (!Addvendorlbl)
            Addvendorlbl=[[UILabel alloc] init];
        Addvendorlbl.frame=CGRectMake(10, 125,widthfield4, 100);
        [Addvendorlbl setFont:[UIFont systemFontOfSize:20.0f]];
        [Addvendorlbl setBackgroundColor:[UIColor clearColor]];
        [Addvendorlbl setTextColor:[UIColor whiteColor]];
        
        [Addvendorlbl setText:@"Add Pricing From Vendor"];
        Addvendorlbl.lineBreakMode = NSLineBreakByWordWrapping;
        Addvendorlbl.numberOfLines = 2;
        [Addvendorlbl setTextAlignment:NSTextAlignmentLeft];
        [OrderingInfoView addSubview:Addvendorlbl];
        if (!AddOpVendorBtn)
            AddOpVendorBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        AddOpVendorBtn.frame=CGRectMake(Addvendorlbl.frame.size.width, 150,widthfield4+10, 40);
        [AddOpVendorBtn addTarget:self action:@selector(AddOpVendorClicked) forControlEvents:UIControlEventTouchUpInside];
        [AddOpVendorBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        //[AddOpVendorBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
        
        [AddOpVendorBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"drop-down-icon" ofType:@"png"]] forState:UIControlStateNormal];
        
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [OrderingInfoView addSubview:AddOpVendorBtn];
        
        if (!OpVendorslistTable)
            OpVendorslistTable = [[UITableView alloc] initWithFrame:CGRectMake(Addvendorlbl.frame.size.width, 50,widthfield4+10, 100) style:UITableViewStylePlain];
        OpVendorslistTable.backgroundColor=[UIColor whiteColor];
        OpVendorslistTable.delegate = self;
        OpVendorslistTable.dataSource = self;
        OpVendorslistTable.scrollEnabled = YES;
        OpVendorslistTable.hidden=YES;
        [OpVendorslistTable.layer setBorderWidth: 1.0];
        [OpVendorslistTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [OrderingInfoView addSubview:OpVendorslistTable];
        
        
        if (!OrderingInfoTable)
            OrderingInfoTable = [[UITableView alloc] initWithFrame:CGRectMake(10, 200,OrderingInfoView.frame.size.width-20, 300) style:UITableViewStylePlain];
        OrderingInfoTable.backgroundColor=[UIColor whiteColor];
        OrderingInfoTable.delegate = self;
        OrderingInfoTable.dataSource = self;
        OrderingInfoTable.scrollEnabled = YES;
        
        [OrderingInfoTable.layer setBorderWidth: 1.0];
        [OrderingInfoTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [OrderingInfoView addSubview:OrderingInfoTable];
        
        @autoreleasepool {
            SaveOrderingInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SaveOrderingInfoBtn.frame=CGRectMake(widthfield4+120,540,80,30);
            [SaveOrderingInfoBtn addTarget:self action:@selector(SaveorderingInfo) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SaveOrderingInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[SaveOrderingInfoBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [SaveOrderingInfoBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            [OrderingInfoView addSubview:SaveOrderingInfoBtn];
            
            CancelOrderingInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelOrderingInfoBtn.frame=CGRectMake(widthfield4+220,540,80,30);
            [CancelOrderingInfoBtn addTarget:self action:@selector(CancelOrderingInfo) forControlEvents:UIControlEventTouchUpInside];
            [CancelOrderingInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            //[CancelOrderingInfoBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            
            [CancelOrderingInfoBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [OrderingInfoView addSubview:CancelOrderingInfoBtn];
            
        }
        
        
    }else if (selectedbtn==101){
        if (!HistoryPopupView)
            HistoryPopupView=[[UIView alloc]init];
        if (isLandScope) {
            HistoryPopupView.frame=CGRectMake(0, 0, 1024, 768);
        }
        
        else{
            
            HistoryPopupView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [HistoryPopupView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:HistoryPopupView];
        if (!HistoryView)
            HistoryView=[[UIView alloc] init];
        if (isLandScope)
        {
            HistoryView.frame=CGRectMake(50, 100, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-200);
        }
        else
        {
            HistoryView.frame=CGRectMake(50, 150, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-400);
        }
        
        
        [HistoryView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [HistoryView.layer setBorderWidth:2.0];
        [HistoryView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [HistoryPopupView addSubview:HistoryView];
        
        
        CGFloat widthfield5=(HistoryView.frame.size.width)/4;
        if (!Historytextlbl)
            Historytextlbl=[[UILabel alloc] init];
        Historytextlbl.frame=CGRectMake(widthfield5+120,10,widthfield5,40);
        [Historytextlbl setFont:[UIFont systemFontOfSize:25.0f]];
        [Historytextlbl setBackgroundColor:[UIColor clearColor]];
        [Historytextlbl setTextColor:[UIColor whiteColor]];
        [Historytextlbl setText:@"Sales History"];
        [Historytextlbl setTextAlignment:NSTextAlignmentLeft];
        [HistoryView addSubview:Historytextlbl];
        if (!SalesHistoryTable)
            SalesHistoryTable = [[UITableView alloc] initWithFrame:CGRectMake(10,60,HistoryView.frame.size.width-20, 400) style:UITableViewStylePlain];
        SalesHistoryTable.backgroundColor=[UIColor whiteColor];
        SalesHistoryTable.delegate = self;
        SalesHistoryTable.dataSource = self;
        SalesHistoryTable.scrollEnabled = YES;
        
        [SalesHistoryTable.layer setBorderWidth: 1.0];
        [SalesHistoryTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [HistoryView addSubview:SalesHistoryTable];
        if (!saveHistoryBtn)
            saveHistoryBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        saveHistoryBtn.frame=CGRectMake(widthfield5+160,500,80,30);
        [saveHistoryBtn addTarget:self action:@selector(Savehistory) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [saveHistoryBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[saveHistoryBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [saveHistoryBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        
        [HistoryView addSubview:saveHistoryBtn];
        NSString *querySQL1 = [NSString stringWithFormat: @"SELECT item_id, discount,total_tax,item_name,item_desscription,price_you_charge,avg_cost,item_quantity,invoice_id,unique_id,created_timestamp,payment_type,in_department,in_vendor,store_id,status,employee,customer FROM invoice_items_table WHERE item_id='%@'",InvItemNumber];
        
        invoiceItemsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL1 resultsArray:invoiceItemsArray];
        
        itemIDArray=[[NSMutableArray alloc]init];
        for (NSDictionary *myDict in invoiceItemsArray)
        {
            [itemIDArray addObject:[myDict objectForKey:@"item_id"]];
        }
        SnosArray=[[NSMutableArray alloc]init];
        
        for (int i=1;i<=[itemIDArray count] ; i++)
        {
            [SnosArray  addObject:[NSString stringWithFormat:@"%d",i]];
            
        }
    }
    
}
-(void)SaveModifierData
{
    [self modifierlViewRemove];
}
-(void)ModifierCancelClicked
{
    [self modifierlViewRemove];
}
-(void)ModifierItemClicked
{
    if (ItemsListTable.hidden==1)
    {
        
        ItemsListTable.hidden=NO;
        
    }
    else if (ItemsListTable.hidden==0)
    {
        
        [ItemsListTable setHidden:YES];
        
    }
    
}
-(void)OptionalinfoFieldClicked:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    
    if (selected == 100)
    {
        
        OPBonusPoints=sender.text;
    }
    if (selected == 101)
    {
        OPBarcodes=sender.text;
    }
    if (selected == 102)
    {
    OPlocation=sender.text;
    }
    if (selected == 103)
    {
        
        OPunitsize=sender.text;
    }
    if (selected == 104)
    {
        
        OPunittype=sender.text;
    }
   
}
-(void)CommisionBtnClicked
{
    if (CommissionsTable.hidden==1)
    {
       
        CommissionsTable.hidden=NO;
        
    }
    else if (CommissionsTable.hidden==0)
    {
       
        [CommissionsTable setHidden:YES];
        
    }
}
-(void)AddvendorDetailsView
{
    if (!AddORVendorDetailsPopUp)
    AddORVendorDetailsPopUp=[[UIView alloc]init];
    if (isLandScope) {
        AddORVendorDetailsPopUp.frame=CGRectMake(0, 0, 1024, 768);
    }
    
    else{
        
        AddORVendorDetailsPopUp.frame=CGRectMake(0, 0, 768, 1024);
    }
    [AddORVendorDetailsPopUp setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:AddORVendorDetailsPopUp];
     if (!AddORVendordetailsView)
    AddORVendordetailsView=[[UIScrollView alloc]init];
    if (isLandScope)
    {
        AddORVendordetailsView.frame=CGRectMake(200, 100, AddORVendorDetailsPopUp.frame.size.width-400, AddORVendorDetailsPopUp.frame.size.height-250);
    }else{
        AddORVendordetailsView.frame=CGRectMake(100, 200, AddORVendorDetailsPopUp.frame.size.width-200, AddORVendorDetailsPopUp.frame.size.height-500);
    }
    
    [AddORVendordetailsView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    
    [AddORVendordetailsView.layer setBorderWidth:2.0];
    [AddORVendordetailsView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
    //AddORVendordetailsView=8;
    [AddORVendorDetailsPopUp addSubview:AddORVendordetailsView];
    
    CGFloat Vendrowidth=(AddORVendordetailsView.frame.size.width)/2;
    CGFloat Vendor=Vendrowidth/2;
      if (!AddVendorDetailsLbl)
    AddVendorDetailsLbl=[[UILabel alloc] init];
    AddVendorDetailsLbl.frame=CGRectMake(Vendor-40, 0,Vendrowidth-20, 100);
   [AddVendorDetailsLbl setFont:[UIFont systemFontOfSize:25.0f]];
    [AddVendorDetailsLbl setBackgroundColor:[UIColor clearColor]];
    [AddVendorDetailsLbl setTextColor:[UIColor whiteColor]];
    [AddVendorDetailsLbl setText:@"Add Vendor Details"];
    AddVendorDetailsLbl.lineBreakMode = NSLineBreakByWordWrapping;
    AddVendorDetailsLbl.numberOfLines = 2;
    [AddVendorDetailsLbl setTextAlignment:NSTextAlignmentLeft];
    [AddORVendordetailsView addSubview:AddVendorDetailsLbl];
    NSArray *labelArray;
    if (!labelArray)
     labelArray=[[NSArray alloc] initWithObjects:@"Vendor Part#",@"Cost Per",@"Case Cost",@"Number In Case ",nil];
    int Ven=80;
    for (int i=0; i<4; i++)
    {
        OrVendorlbl=[[UILabel alloc] init];
        OrVendorlbl.frame=CGRectMake(Vendor-40, Ven,Vendrowidth+10, 40);
        
        OrVendorlbl.tag=i+100;
        [OrVendorlbl setFont:[UIFont systemFontOfSize:20.0f]];
        [OrVendorlbl setBackgroundColor:[UIColor clearColor]];
        [OrVendorlbl setTextColor:[UIColor whiteColor]];
         [OrVendorlbl setText:[labelArray objectAtIndex:i]];
        [OrVendorlbl setTextAlignment:NSTextAlignmentLeft];
        [AddORVendordetailsView addSubview:OrVendorlbl];
        //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
        VendorField=[[UITextField alloc] init];
        //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
       
        VendorField.frame=CGRectMake(Vendor+OrVendorlbl.frame.size.width-130, Ven,Vendrowidth-60, 40);
        
        VendorField.delegate=self;
        VendorField.tag=i+100;
        
        UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
        
        VendorField.leftView = paddingview;
        VendorField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
        VendorField.leftViewMode = UITextFieldViewModeAlways;
        //[VendorField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
        [VendorField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
        paddingview=nil;
        if (VendorField.tag==100)
        {
            VendorField.text=VendorpartStr;
        }
        if (VendorField.tag==101)
        {
            VendorField.text=CostperStr;
        }
        if (VendorField.tag==102)
        {
            VendorField.text=CaseCostStr;
        }
        if (VendorField.tag==103)
        {
            VendorField.text=Numberincasestr;
        }
        
        [VendorField addTarget:self action:@selector(OrderInfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
        [VendorField setAutocorrectionType:UITextAutocorrectionTypeNo];
        
        //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
        
        [AddORVendordetailsView addSubview:VendorField];
        
        Ven=Ven+60;

    }
    // //NSLog(@"%d",Ven);
      if (!Preferredlbl)
    Preferredlbl=[[UILabel alloc]init];
    Preferredlbl.frame=CGRectMake(Vendor-40, 320,Vendrowidth+10, 40);
    [Preferredlbl setText:@"Preferred"];
    [Preferredlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Preferredlbl setBackgroundColor:[UIColor clearColor]];
    [Preferredlbl setTextColor:[UIColor whiteColor]];
    [AddORVendordetailsView addSubview:Preferredlbl];
     if (!trueRadioBtn)
    trueRadioBtn = [[UIButton alloc] init];
    trueRadioBtn.frame=CGRectMake(Vendor+Preferredlbl.frame.size.width-130, 325,25, 25);
    [trueRadioBtn setTag:0];
    //[trueRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
      [trueRadioBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"radio-off" ofType:@"png"]] forState:UIControlStateNormal];
    
    //[trueRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
      [trueRadioBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"radio-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [trueRadioBtn addTarget:self action:@selector(radiobuttonSelected3:) forControlEvents:UIControlEventTouchUpInside];
    if (!Truelbl)
    Truelbl=[[UILabel alloc]init];
    Truelbl.frame=CGRectMake(Vendor+Preferredlbl.frame.size.width-130+42, 320,Vendrowidth-100,45 );
    [Truelbl setText:@"True"];
    [Truelbl setFont:[UIFont systemFontOfSize:20.0f]];
    [Truelbl setBackgroundColor:[UIColor clearColor]];
    [Truelbl setTextColor:[UIColor whiteColor]];
    [AddORVendordetailsView addSubview:Truelbl];
    
    if (!falseRadioBtn)
    falseRadioBtn = [[UIButton alloc] init];
    falseRadioBtn.frame=CGRectMake(Vendor+OrVendorlbl.frame.size.width-220+Truelbl.frame.size.width, 325,25, 25);
    [falseRadioBtn setTag:1];
   // [falseRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-off.png"] forState:UIControlStateNormal];
    //[falseRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
    [falseRadioBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"radio-off" ofType:@"png"]] forState:UIControlStateNormal];
    
    //[trueRadioBtn setBackgroundImage:[UIImage imageNamed:@"radio-on.png"] forState:UIControlStateSelected];
    [falseRadioBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"radio-on" ofType:@"png"]] forState:UIControlStateSelected];
    
    [falseRadioBtn addTarget:self action:@selector(radiobuttonSelected3:) forControlEvents:UIControlEventTouchUpInside];
    
    if ([PreferredStr isEqualToString:@"True"])
    {
          [trueRadioBtn setSelected:YES];
    }
    else if ([PreferredStr isEqualToString:@"False"])
     {
       [falseRadioBtn setSelected:YES];
      
    }
    [AddORVendordetailsView addSubview:falseRadioBtn];
    [AddORVendordetailsView addSubview:trueRadioBtn];
    
     if (!falselbl)
    falselbl=[[UILabel alloc]init];
    falselbl.frame=CGRectMake(Vendor+OrVendorlbl.frame.size.width-220+Truelbl.frame.size.width+42, Ven,Vendrowidth-60, 40);
    [falselbl setText:@"False"];
    [falselbl setFont:[UIFont systemFontOfSize:20.0f]];
    [falselbl setBackgroundColor:[UIColor clearColor]];
    [falselbl setTextColor:[UIColor whiteColor]];
    [AddORVendordetailsView addSubview:falselbl];
    
    
    @autoreleasepool {
        SaveORVendorDetailsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        SaveORVendorDetailsBtn.frame=CGRectMake(Vendrowidth-80, 400, 80, 30);
        [SaveORVendorDetailsBtn addTarget:self action:@selector(SaveVendorDetailsClicked) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [SaveORVendorDetailsBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[SaveORVendorDetailsBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [SaveORVendorDetailsBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        [AddORVendordetailsView addSubview:SaveORVendorDetailsBtn];
        
        CancelORVendorDetailsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        CancelORVendorDetailsBtn.frame=CGRectMake(Vendrowidth+60, 400, 80, 30);
        [CancelORVendorDetailsBtn addTarget:self action:@selector(CancelVendordetailsClicked) forControlEvents:UIControlEventTouchUpInside];
        [CancelORVendorDetailsBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[CancelORVendorDetailsBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        [CancelORVendorDetailsBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [AddORVendordetailsView addSubview:CancelORVendorDetailsBtn];
    }
    
    
   

}
-(void)radiobuttonSelected3:(id)sender{
    
    switch ([sender tag]) {
        case 0:
            if([trueRadioBtn isSelected]==YES)
            {
                [trueRadioBtn setSelected:NO];
                [falseRadioBtn setSelected:YES];
                
                
            }
            else{
                [trueRadioBtn setSelected:YES];
                [falseRadioBtn setSelected:NO];
                PreferredStr=@"True";
                
            }
            
            break;
        case 1:
            if([falseRadioBtn isSelected]==YES)
            {
                [falseRadioBtn setSelected:NO];
                [trueRadioBtn setSelected:YES];
                
            }
            else{
                [falseRadioBtn setSelected:YES];
                [trueRadioBtn setSelected:NO];
                  PreferredStr=@"False";
                
            }
            break;
        default:
            break;
    }
}
-(void)OrderInfoFieldClicked:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    if (selected==100)
    {
        VendorpartStr=sender.text;
    }
    
    if (selected == 101)
    {
        CostperStr=sender.text;
    }
    if (selected == 102)
    {
        CaseCostStr=sender.text;
    }
    if (selected == 103)
    {
        
        Numberincasestr=sender.text;
    }
    
}

-(void)SaveVendorDetailsClicked
{
    
    if (selectedorderinfo)
    {
        
        [VendorPartsArray removeObjectAtIndex:selectedOrder];
        [CostpersArray removeObjectAtIndex:selectedOrder];
        [CasecostsArray removeObjectAtIndex:selectedOrder];
        [NumberincasesArray removeObjectAtIndex:selectedOrder];
        [preferredsArray removeObjectAtIndex:selectedOrder];
        
        [VendorPartsArray insertObject:VendorpartStr atIndex:selectedOrder];
         [CostpersArray insertObject:CostperStr atIndex:selectedOrder];
         [CasecostsArray insertObject:CaseCostStr atIndex:selectedOrder];
         [NumberincasesArray insertObject:Numberincasestr atIndex:selectedOrder];
        
        // //NSLog(@"preferred array  %@",preferredsArray);
        
        if ([preferredsArray count]>1)
        {
            NSUInteger objIdx = [preferredsArray containsObject:@"True"];
            // //NSLog(@"%lu",(unsigned long)objIdx);
          if(objIdx == 1)
         {
            NSInteger index=[preferredsArray indexOfObject:@"True"];
            
            if ([PreferredStr isEqualToString:@"True"])
            {
                [preferredsArray removeObjectAtIndex:index];
                [preferredsArray insertObject:@"False" atIndex:index];
                [preferredsArray insertObject:PreferredStr atIndex:selectedOrder];
            }
            
            else
            {
                 [preferredsArray insertObject:PreferredStr atIndex:selectedOrder];
            }
         }
            else
            {
                [preferredsArray insertObject:PreferredStr atIndex:selectedOrder];
            }
         }
   }
    else
    {
    if ([VendorpartStr length]>0)
    {
        [VendorPartsArray addObject:VendorpartStr];
    }
    else
    {
        [VendorPartsArray addObject:@""];
    }
    if ([CostperStr length]>0)
    {
        [CostpersArray addObject:CostperStr];
    }
    else
    {
        [CostpersArray addObject:@""];
    }
    if ([CaseCostStr length]>0)
    {
        [CasecostsArray addObject:CaseCostStr];
    }
    else
    {
        [CasecostsArray addObject:@""];
    }
    if ([Numberincasestr length]>0)
    {
        [NumberincasesArray addObject:Numberincasestr];
    }
    else
    {
        [NumberincasesArray addObject:@""];
    }
    
        // //NSLog(@"%@",PreferredStr);
        
    if ([preferredsArray count]>0)
    {
        NSUInteger objIdx = [preferredsArray containsObject:@"True"];
        // //NSLog(@"%lu",(unsigned long)objIdx);
        if(objIdx == 1)
        {
        NSInteger index=[preferredsArray indexOfObject:@"True"];
        
         if ([PreferredStr isEqualToString:@"True"])
           {
            [preferredsArray removeObjectAtIndex:index];
            [preferredsArray insertObject:@"False" atIndex:index];
            [preferredsArray addObject:PreferredStr];
            }
         else
         {
             [preferredsArray addObject:PreferredStr];
         }
        }
        else
        {
            [preferredsArray addObject:PreferredStr];
        }
    }
    else
    {
          [preferredsArray addObject:PreferredStr];
    }
    }
    // //NSLog(@"Pre Count %d",[preferredsArray count]);
        


    
    NSArray * depertmentViewArray = AddvendorsView.subviews;
    for (int i = 0; i<[depertmentViewArray count]; i++) {
        UIView *vi =[depertmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addDepartmentViewArray = AddORVendorDetailsPopUp.subviews;
    for (int i = 0; i<[addDepartmentViewArray count]; i++) {
        UIView *vi =[addDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [AddvendorsView removeFromSuperview],[AddORVendorDetailsPopUp removeFromSuperview];
   
    
    [OrderingInfoTable reloadData];
    VendorpartStr=@"";
    CostperStr=@"";
    CaseCostStr=@"";
    Numberincasestr=@"";
    PreferredStr=@"";
    
    selectedorderinfo=NO;

}

-(void)CancelVendordetailsClicked
{
    
    NSArray * depertmentViewArray = AddvendorsView.subviews;
    for (int i = 0; i<[depertmentViewArray count]; i++) {
        UIView *vi =[depertmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addDepartmentViewArray = AddORVendorDetailsPopUp.subviews;
    for (int i = 0; i<[addDepartmentViewArray count]; i++) {
        UIView *vi =[addDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [AddvendorsView removeFromSuperview],[AddORVendorDetailsPopUp removeFromSuperview];

}
-(void)AddskusClicked
{
    if (!AddskupopupView)
    AddskupopupView=[[UIView alloc]init];
    if (isLandScope) {
        AddskupopupView.frame=CGRectMake(0, 0, 1024, 768);
    }
    
    else{
        
        AddskupopupView.frame=CGRectMake(0, 0, 768, 1024);
    }
    [AddskupopupView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:AddskupopupView];
     if (!addskuView)
    addskuView=[[UIScrollView alloc]init];
    if (isLandScope)
    {
        addskuView.frame=CGRectMake(200, 200, AddskupopupView.frame.size.width-400, AddskupopupView.frame.size.height-400);
    }
    else
    {
        addskuView.frame=CGRectMake(100, 300, AddskupopupView.frame.size.width-200, AddskupopupView.frame.size.height-700);
    }
    
    [addskuView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    
    [addskuView.layer setBorderWidth:2.0];
    [addskuView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
    //AddvendorsView.layer.cornerRadius=8;
    [AddskupopupView addSubview:addskuView];
    
    CGFloat skuwidth=(addskuView.frame.size.width);
      if (!skuTextlbl)
    skuTextlbl=[[UILabel alloc] init];
    skuTextlbl.frame=CGRectMake(10, 20,skuwidth-20, 100);
    
    [skuTextlbl setFont:[UIFont systemFontOfSize:20.0f]];
    [skuTextlbl setBackgroundColor:[UIColor clearColor]];
    [skuTextlbl setTextColor:[UIColor whiteColor]];
    [skuTextlbl setText:@"Enter the alternate sku's would you like to add to this item number"];
    skuTextlbl.lineBreakMode = NSLineBreakByWordWrapping;
    skuTextlbl.numberOfLines = 2;
    [skuTextlbl setTextAlignment:NSTextAlignmentLeft];
    [addskuView addSubview:skuTextlbl];
      if (!SkuField)
    SkuField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    SkuField.frame=CGRectMake(15, 100,skuwidth-30, 40);
    SkuField.delegate=self;
   
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    SkuField.leftView = paddingview;
    SkuField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    SkuField.leftViewMode = UITextFieldViewModeAlways;
    //[SkuField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [SkuField setBackground:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"addinputtextfield" ofType:@"png"]]];
    [SkuField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [addskuView addSubview:SkuField];
     paddingview=nil;
    @autoreleasepool {
        saveSkuBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        saveSkuBtn.frame=CGRectMake(skuwidth-400, 180, 80, 30);
        [saveSkuBtn addTarget:self action:@selector(SaveSkusClicked) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [saveSkuBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[saveSkuBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [saveSkuBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"savegreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        [addskuView addSubview:saveSkuBtn];
        
        CancelSkuBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        CancelSkuBtn.frame=CGRectMake(skuwidth-220, 180, 80, 30);
        [CancelSkuBtn addTarget:self action:@selector(CancelSkuClicked) forControlEvents:UIControlEventTouchUpInside];
        [CancelSkuBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        //[CancelSkuBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        [CancelSkuBtn setBackgroundImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cancelgreenbutton" ofType:@"png"]] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [addskuView addSubview:CancelSkuBtn];
    }
  
   

}
-(void)SaveSkusClicked
{
    SkuStr=SkuField.text;
    if (!allSkusArray)
    allSkusArray=[[NSMutableArray alloc]init];
    
     NSString *querySQL = [NSString stringWithFormat: @"SELECT alternate_sku_value FROM alternate_sku"];
    
    NSMutableArray *skusArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:skusArray];
    
    for (NSDictionary *myDict in skusArray)
    {
        [allSkusArray addObject:[myDict objectForKey:@"alternate_sku_value"]];
    }
    if ([SkusArray count]>0)
    {
        NSUInteger objIdx = [SkusArray containsObject:SkuStr];
         NSUInteger objIdy = [allSkusArray containsObject:SkuStr];
        
        // //NSLog(@"%lu",(unsigned long)objIdx);
        if(objIdx == 0)
        {
          if ( objIdy==0)
          {
                [SkusArray addObject:SkuStr];
                [AlternateTable reloadData];
                [self skuViewRemove];
            }
           
        }
        else
        {
            
            UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"This Sku already exist please change the Sku" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
            [alert show];
            alert=nil;
        }
    }
    else
    {
        [SkusArray addObject:SkuStr];
        [AlternateTable reloadData];
         [self skuViewRemove];
    }
   

   
   
}
-(void) skuViewRemove
{
   
    NSArray * depertmentViewArray = addskuView.subviews;
    for (int i = 0; i<[depertmentViewArray count]; i++) {
        UIView *vi =[depertmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addDepartmentViewArray = AddskupopupView.subviews;
    for (int i = 0; i<[addDepartmentViewArray count]; i++) {
        UIView *vi =[addDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addskuView removeFromSuperview],[AddskupopupView removeFromSuperview];
}
-(void)CancelSkuClicked

{
    [self skuViewRemove];
}

-(void)ItemBtnClicked:(UIButton *)sender
{
    NSInteger selecteditem=sender.tag;
    
    if (selecteditem==100)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
             modifierItem=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
            modifierItem=@"yes";
        }
    }
    if (selecteditem==101)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
             CountthisItem=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
             CountthisItem=@"yes";
        }
    }
    if (selecteditem==102)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
             allowbuyback=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
              allowbuyback=@"yes";
        }
    }
    if (selecteditem==103)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
             printonreceipt=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
              printonreceipt=@"yes";
        }
    }
    if (selecteditem==104)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
             foodstampable=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
              foodstampable=@"yes";
        }
    }
    if (selecteditem==105)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
            Promptprice=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
            Promptprice=@"yes";
        }
    }
    
   

}
-(void)SaveOptionalInfo
{
      OPCommission=[NSString stringWithFormat:@"%@",optCommissionBtn.titleLabel.text];
    [self optionalInfoViewRemove];
}
-(void)PricelevelCancelclicked
{
    [PriceLevelsBackView removeFromSuperview];
}
-(void)OpenRadioBtnClciked
{
    if (OpenRadioBtn.selected)
    {
        [OpenRadioBtn setSelected:NO];
        
    }
    else if(!OpenRadioBtn.selected)
    {
        [OpenRadioBtn setSelected:YES];
        [CompleteRadioBtn setSelected:NO];
        [CancelRadioBtn setSelected:NO];
        
    }
    
}
-(void)SaveProductNotes
{
    Productnotes=NotesTextView.text;
    [self notesViewRemove];
    
}
-(void)IndividualRadioBtnClicked
{
    
    if (IndividualRadioBtn.selected)
    {
        [IndividualRadioBtn setSelected:NO];
        
    }
    else if(!IndividualRadioBtn.selected)
    {
        [IndividualRadioBtn setSelected:YES];
        [GroupRadioBtn setSelected:NO];
        [ModifierGroupView removeFromSuperview];
        [ModifierView addSubview:ModIndividualView];
    }
   
}
-(void)GroupRadioBtnClicked
{
    
    if (GroupRadioBtn.selected)
    {
        [GroupRadioBtn setSelected:NO];
        
    }
    else if(!GroupRadioBtn.selected)
    {
        [GroupRadioBtn setSelected:YES];
        [IndividualRadioBtn setSelected:NO];
        [ModIndividualView removeFromSuperview];
        [ModifierView addSubview:ModifierGroupView];
    }
    
    
}
-(void)CompleteRadioBtnClicked
{
    if (CompleteRadioBtn.selected)
    {
        [CompleteRadioBtn setSelected:NO];
        
    }
    else if(!CompleteRadioBtn.selected)
    {
        [CompleteRadioBtn setSelected:YES];
        [OpenRadioBtn setSelected:NO];
        [CancelRadioBtn setSelected:NO];
        
    }
}
-(void)CancelRadioBtnClicked
{
    if (CancelRadioBtn.selected)
    {
        [CancelRadioBtn setSelected:NO];
        
    }
    else if(!CancelRadioBtn.selected)
    {
        [CancelRadioBtn setSelected:YES];
        [OpenRadioBtn setSelected:NO];
        [CompleteRadioBtn setSelected:NO];
        
    }
    
}
-(void)orderingInfoViewRemove
{
    NSArray * depertmentViewArray = OrderingInfoView.subviews;
    for (int i = 0; i<[depertmentViewArray count]; i++) {
        UIView *vi =[depertmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addDepartmentViewArray = OrderingInfoBackView.subviews;
    for (int i = 0; i<[addDepartmentViewArray count]; i++) {
        UIView *vi =[addDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [OrderingInfoView removeFromSuperview],[OrderingInfoBackView removeFromSuperview];
}
-(void) historyViewRemove
{
   
    NSArray * depertmentViewArray = HistoryView.subviews;
    for (int i = 0; i<[depertmentViewArray count]; i++) {
        UIView *vi =[depertmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addDepartmentViewArray = HistoryPopupView.subviews;
    for (int i = 0; i<[addDepartmentViewArray count]; i++) {
        UIView *vi =[addDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [HistoryView removeFromSuperview],[HistoryPopupView removeFromSuperview];

}

-(void)Savehistory
{
    [self historyViewRemove];
    
}
-(void)SaveorderingInfo
{
    [self orderingInfoViewRemove];
}
-(void)CancelOrderingInfo
{ [self orderingInfoViewRemove];
}
-(void)AddOpVendorClicked
{
    //OpVendorslistTable
    if (OpVendorslistTable.hidden==1)
    {
      
        OpVendorslistTable.hidden=NO;
        
    }
    else if (OpVendorslistTable.hidden==0)
    {
       
        [OpVendorslistTable setHidden:YES];
        
    }
    
}
-(void)IndividualmodifierCancelclicked
{
    [ModifierBackView removeFromSuperview];
}
-(void)GropumodifierCancelclicked
{
    [ModifierBackView removeFromSuperview];
}
-(void)PendingInfoCancelclicked
{
    [PendingOrderBackView removeFromSuperview];
}
-(void)OptionalInfoCancelclicked
{
    [self optionalInfoViewRemove];
}
-(void)NotesCancelclicked
{
    [self notesViewRemove];
}

-(void)PriceYouChargeClicked:(UITextField *)sender
{
   
    
}
-(void)Tax1Clicked
{
    if (tax1Btn.selected)
    {
        [tax1Btn setSelected:NO];
        
    }else if(!tax1Btn.selected)
    {
        [tax1Btn setSelected:YES];

    }
    [self Totaltaxmethod];
}
-(void)Tax2Clikced
{
    if (tax2Btn.selected){
        [tax2Btn setSelected:NO];
        
    }else if(!tax2Btn.selected)
    {
        [tax2Btn setSelected:YES];
        
    }
    [self Totaltaxmethod];
}
-(void)Tax3Clicked
{
    if (tax3Btn.selected){
        [tax3Btn setSelected:NO];
        
    }else if(!tax3Btn.selected)
    {
        [tax3Btn setSelected:YES];
        
    }
    [self Totaltaxmethod];
}
-(void)BarBtnClicked
{
    if (BarTaxBtn.selected){
        [BarTaxBtn setSelected:NO];
        
    }else if(!BarTaxBtn.selected)
    {
        [BarTaxBtn setSelected:YES];
        
    }
    [self Totaltaxmethod];
}
-(void)Totaltaxmethod
{
    costStr=PriceyouChargeField.text;
    
    
    
    if (BarTaxBtn.selected || !tax1Btn.selected)
    {
        taxvalue=[costStr doubleValue];
        TaxValueStr=@"Bartax";
        ProductTotalTax=0;
        
    }
    if (tax1Btn.selected)
    {
        double pcntYes=(([tax1Rate doubleValue]*[costStr doubleValue])/100);
        // //NSLog(@"%f",pcntYes);
        taxvalue=[costStr doubleValue]+pcntYes;
        TaxValueStr=tax1Name;
       
        ProductTotalTax=[tax1Rate floatValue];
        
    }
    if (tax2Btn.selected)
    {
        double pcntYes=(([tax2Rate doubleValue]*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        TaxValueStr=tax2Name;
        
        ProductTotalTax=[tax2Rate floatValue];
        
    }
    if (tax3Btn.selected)
    {
        double pcntYes=(([tax3Rate doubleValue]*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        TaxValueStr=tax3Name;
       
        ProductTotalTax=[tax3Rate floatValue];
        
    }
    if (tax1Btn.selected && tax2Btn.selected)
    {
        double pcntYes=((([tax1Rate doubleValue]+[tax2Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name, nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
    
        ProductTotalTax=[tax1Rate floatValue]+[tax2Rate floatValue];
        [taxesArray removeAllObjects],taxesArray=nil;
    }
    
    if (tax1Btn.selected  && tax3Btn.selected)
    {
        double pcntYes=((([tax1Rate doubleValue]+[tax3Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax3Name, nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        
        ProductTotalTax=[tax1Rate floatValue]+[tax3Rate floatValue];
         [taxesArray removeAllObjects],taxesArray=nil;
        
    }
    if (tax2Btn.selected  && tax3Btn.selected)
    {
        double pcntYes=((([tax3Rate doubleValue]+[tax2Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,tax3Name, nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        
        ProductTotalTax=[tax2Rate floatValue]+[tax3Rate floatValue];
         [taxesArray removeAllObjects],taxesArray=nil;
        
    }
    if (tax1Btn.selected && tax2Btn.selected && tax3Btn.selected)
    {
        double pcntYes=((([tax1Rate doubleValue]+[tax2Rate doubleValue]+[tax3Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,tax3Name, nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
       
        ProductTotalTax=[tax1Rate floatValue]+[tax2Rate floatValue]+[tax3Rate floatValue];
         [taxesArray removeAllObjects],taxesArray=nil;
        
    }
    if (tax1Btn.selected && BarTaxBtn.selected)
    {
        double pcntYes=(([tax1Rate doubleValue]*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
       
         [taxesArray removeAllObjects],taxesArray=nil;
        ProductTotalTax=[tax1Rate floatValue];
    }
    if (tax2Btn.selected && BarTaxBtn.selected)
    {
        
        
        double pcntYes=(([tax2Rate doubleValue]*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        [taxesArray removeAllObjects],taxesArray=nil;
        ProductTotalTax=[tax2Rate floatValue];
    }
    if (tax3Btn.selected && BarTaxBtn.selected)
    {
        
        double pcntYes=(([tax3Rate doubleValue]*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax3Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        
        ProductTotalTax=[tax3Rate floatValue];
         [taxesArray removeAllObjects],taxesArray=nil;
        
    }
    if (tax1Btn.selected && tax2Btn.selected && BarTaxBtn.selected)
    {
        
        double pcntYes=((([tax1Rate doubleValue]+[tax2Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
     [taxesArray removeAllObjects],taxesArray=nil;
        ProductTotalTax=[tax1Rate floatValue]+[tax2Rate floatValue];
    }
    
    if (tax1Btn.selected  && tax3Btn.selected && BarTaxBtn.selected)
    {
        
        double pcntYes=((([tax1Rate doubleValue]+[tax3Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax3Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
      
        ProductTotalTax=[tax1Rate floatValue]+[tax3Rate floatValue];
    }
    if (tax2Btn.selected  && tax3Btn.selected && BarTaxBtn.selected)
    {
        
        double pcntYes=((([tax3Rate doubleValue]+[tax2Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,tax3Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        [taxesArray removeAllObjects],taxesArray=nil;
        
        ProductTotalTax=[tax3Rate floatValue]+[tax2Rate floatValue];
    }
    if (tax1Btn.selected && tax2Btn.selected && tax3Btn.selected && BarTaxBtn.selected)
    {
        
        double pcntYes=((([tax1Rate doubleValue]+[tax2Rate doubleValue]+[tax3Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,tax3Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
       
        ProductTotalTax=[tax1Rate floatValue]+[tax2Rate floatValue]+[tax3Rate floatValue];
       [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (!tax1Btn.selected && !tax2Btn.selected && !tax3Btn.selected && !BarTaxBtn.selected)
    {
        ProductTotalTax=0;
        TaxValueStr=@"";
    }
    // //NSLog(@"tax value %@",TaxValueStr);
    totalTaxStr=[NSString stringWithFormat:@"%f",taxvalue];
   
    [PriceWithTaxBtn setTitle:[NSString stringWithFormat:@"%0.02f",taxvalue] forState:UIControlStateNormal];
    
}
-(void)pricewithTaxClicked
{
    
    [self Totaltaxmethod];
   

}
#pragma mark - save Product Data  Methods

-(void)SaveProductData
{
    NSString *departmentstr=[NSString stringWithFormat:@"%@",DepartmentBtn.titleLabel.text];
    NSString *vendorstr=[NSString stringWithFormat:@"%@",AddpricingBtn.titleLabel.text];
    NSString *pricewithtax=[NSString stringWithFormat:@"%@",PriceWithTaxBtn.titleLabel.text];
     OPCommission=[NSString stringWithFormat:@"%@",optCommissionBtn.titleLabel.text];
    
    if (!ItemNumbersArray)
    ItemNumbersArray=[[NSMutableArray alloc]init];
     NSString *querySQL = [NSString stringWithFormat: @"SELECT inventory_item_no FROM inventorytable"];
    NSMutableArray *productsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:productsArray];
    @autoreleasepool {
        for (NSDictionary *myDict in productsArray)
        {
            NSString *catname=[myDict objectForKey:@"inventory_item_no"];
            
            [ItemNumbersArray addObject:catname];
            catname=nil;
        }
    }
   
     NSString *querySQL7 = [NSString stringWithFormat:@"SELECT department_id,category_id FROM department_details"];
    NSMutableArray *deptsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:deptsArray];
    
    NSString *catdedtstr;
    for (NSDictionary *myDict in deptsArray)
    {
        
        NSString *catname=[myDict objectForKey:@"department_id"];
        if ([catname isEqualToString:departmentstr])
        {
            catdedtstr=[myDict objectForKey:@"category_id"];
        }
        catname=nil;
      
    }
    catdedtstr=nil;
    NSUInteger objIdx = [ItemNumbersArray containsObject:ItemNumberField.text];
    // //NSLog(@"%lu",(unsigned long)objIdx);
    if(objIdx == 0)
    {
        NSString *tstr=[NSString stringWithFormat:@"%f",ProductTotalTax];
        
    NSString *invinsertSQL =@"insert into inventorytable (inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        NSMutableArray *insertsArray=[[NSMutableArray alloc]initWithObjects:departmentstr,ItemNumberField.text,ItemNameField.text,DescriptionText.text,CostField.text,pricewithtax,PriceyouChargeField.text,InStockField.text,@"1",TaxValueStr,vendorstr,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime],tstr,Productnotes,@"true",catdedtstr, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:invinsertSQL withArguments:insertsArray];
        
       
        NSString *querySQL = [NSString stringWithFormat:@"SELECT inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id,server_local FROM inventorytable WHERE inventory_item_no='%@'",ItemNumberField.text];
        NSMutableArray *productDataArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:productDataArray];
        
        NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
        [CategoryDict setObject:productDataArray forKey:@"fields"];
        NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
        
        
        NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet])
        {
        
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str,@"inventorytable",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            // //NSLog(@"%@",str);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=inventorytable&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            CategoryConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [CategoryConnection start];
                 string=nil,request=nil,url=nil;
            }
        }
        
//optionalinfo data
        

        NSString *optinsertSQL=@"insert into optional_info_table (bonus_points,barcodes,location,unit_type,unit_size,commission_optional_info,inventary_modifier_item,inventary_count_this_item,inventary_prompt_quantity,inventary_prompt_price,inventary_print_on_receipt,inventary_foodstampable,inventory_item_no,unique_id,created_timestamp,modified_timestamp) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        NSMutableArray *optionalArray=[[NSMutableArray alloc]initWithObjects:OPBonusPoints,OPBarcodes,OPlocation,OPunittype,OPunitsize,OPCommission,modifierItem,CountthisItem,allowbuyback,Promptprice,printonreceipt,foodstampable,ItemNumberField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject Datestring], nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:optinsertSQL withArguments:optionalArray];
        
         NSString *optquerySQL = [NSString stringWithFormat: @"SELECT bonus_points,barcodes,location,unit_type,unit_size,commission_optional_info,inventary_modifier_item,inventary_count_this_item,inventary_prompt_quantity,inventary_prompt_price,inventary_print_on_receipt,inventary_foodstampable,inventory_item_no,unique_id,created_timestamp,modified_timestamp,server_local FROM optional_info_table WHERE inventory_item_no='%@'",ItemNumberField.text];
        NSMutableArray *optionalinfoDataAray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:optquerySQL resultsArray:optionalinfoDataAray];
        
        NSMutableDictionary *CategoryDict2=[[NSMutableDictionary alloc]init];
        [CategoryDict2 setObject:optionalinfoDataAray forKey:@"fields"];
        
        NSDictionary *jsonDict2 = [NSDictionary dictionaryWithDictionary:CategoryDict2];
        
        
        NSError *err2;
        
        NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:jsonDict2 options:kNilOptions error:&err2];
    
        NSString *str2=[[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
        
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str2,@"optional_info_table",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str2);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=optional_info_table&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str2);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            VendorConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [VendorConnection start];
                 string=nil,request=nil,url=nil;
            }
        }
//skus data
        
        NSString *insertSQL;
        if ([SkusArray count]>0)
        {
            for (int i=0; i<[SkusArray count]; i++)
            {
                NSString *str=[SkusArray objectAtIndex:i];
                
                insertSQL = @"insert into alternate_sku (inventory_item_no, alternate_sku_value,created_timestamp,modified_timestamp,unique_id) VALUES (?,?,?,?,?)";
                NSMutableArray *skusArray=[[NSMutableArray alloc]initWithObjects:ItemNumberField.text,str,[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime],[generalDataObject  genRandStringLength:20], nil];
                
                [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:skusArray];
                insertSQL=nil;
                // //NSLog(@"%@",insertSQL);
            }
        }
        
       NSString *skuquerySQL = [NSString stringWithFormat:@"SELECT inventory_item_no, alternate_sku_value,created_timestamp,modified_timestamp,unique_id,server_local FROM alternate_sku WHERE inventory_item_no='%@'",ItemNumberField.text];
        NSMutableArray *selectdskusArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:skuquerySQL resultsArray:selectdskusArray];
        
        NSMutableDictionary *CategoryDict3=[[NSMutableDictionary alloc]init];
        [CategoryDict3 setObject:selectdskusArray forKey:@"fields"];
        NSDictionary *jsonDict3= [NSDictionary dictionaryWithDictionary:CategoryDict3];
        
        
        NSError *err3;
        
        NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:jsonDict3 options:kNilOptions error:&err3];
        
        NSString *str3=[[NSString alloc] initWithData:jsonData3 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str3,@"alternate_sku",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str3);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=alternate_sku&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str3 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str3);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            SkuConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [SkuConnection start];
                 string=nil,request=nil,url=nil;
            }
        }
//modifiers data
        
        if ([ModifierItemNosArray count]>0)
        {
            NSString *insertSQL2;
            for (int i=0; i<[ModifierItemNosArray count]; i++)
            {
                NSString *str=[ModifierItemNosArray objectAtIndex:i];
                NSString *name=[modifierNamesArray  objectAtIndex:i];
                
                insertSQL2 =@"insert into modifier_table (inventory_item_no, modifier_item_no,inventary_item_name,unique_id,created_timestamp,modified_timestamp) VALUES(?,?,?,?,?,?) ";
                NSMutableArray *modsArray=[[NSMutableArray alloc]initWithObjects:ItemNumberField.text,str,name,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
                [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL2 withArguments:modsArray];
                // //NSLog(@"%@",insertSQL2);
            }
         }
    
        
      NSString *modquerySQL = [NSString stringWithFormat:@"SELECT inventory_item_no, modifier_item_no,inventary_item_name,unique_id,created_timestamp,modified_timestamp,server_local FROM modifier_table WHERE inventory_item_no='%@'",ItemNumberField.text];
        NSMutableArray *modifiersArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:modquerySQL resultsArray:modifiersArray];
        
        NSMutableDictionary *CategoryDict4=[[NSMutableDictionary alloc]init];
        [CategoryDict4 setObject:modifiersArray forKey:@"fields"];
        NSDictionary *jsonDict4= [NSDictionary dictionaryWithDictionary:CategoryDict4];
        
        
        NSError *err4;
        
        NSData *jsonData4 = [NSJSONSerialization dataWithJSONObject:jsonDict4 options:kNilOptions error:&err4];
        
        NSString *str4=[[NSString alloc] initWithData:jsonData4 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str4,@"modifier_table",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str4);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=modifier_table&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str4 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str4);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            ModifierConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [ModifierConnection start];
                 string=nil,request=nil,url=nil;
            }
        }

        
 //ordering info data
        
        if ([SelectedOpVendorsArray count]>0)
        {
            NSString *insertSQL5;
            for (int i=0; i<[SelectedOpVendorsArray count]; i++)
            {
                
                NSString *vendorcomapnyname=[SelectedOpVendorsArray objectAtIndex:i];
                NSString *vendorno=[VendorPartsArray  objectAtIndex:i];
                NSString *casecost=[CasecostsArray objectAtIndex:i];
                NSString *costper=[CostpersArray  objectAtIndex:i];
                NSString *numberincase=[NumberincasesArray objectAtIndex:i];
                NSString *preferred=[preferredsArray  objectAtIndex:i];
                
            insertSQL5 =@"insert into ordering_info_table (venderpart_no,vendor_company_name,cost_per,case_cost,no_in_case,preferred,inventory_item_no,unique_id,created_timestamp,modified_timestamp) values(?,?,?,?,?,?,?,?,?,?)";
                
               NSMutableArray *orderingArray=[[NSMutableArray alloc]initWithObjects:vendorno,vendorcomapnyname,costper,casecost,numberincase,preferred,ItemNumberField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
                [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL5 withArguments:orderingArray];
      
            }
        }

        
     NSString *orderquerySQL = [NSString stringWithFormat:@"SELECT venderpart_no,vendor_company_name,cost_per,case_cost,no_in_case,preferred,inventory_item_no,unique_id,created_timestamp,modified_timestamp,server_local FROM ordering_info_table WHERE inventory_item_no='%@'",ItemNumberField.text];
        NSMutableArray *orderininfosArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:orderquerySQL resultsArray:orderininfosArray];
        
        NSMutableDictionary *CategoryDict5=[[NSMutableDictionary alloc]init];
        [CategoryDict5 setObject:orderininfosArray forKey:@"fields"];
        NSDictionary *jsonDict5= [NSDictionary dictionaryWithDictionary:CategoryDict5];
        
        
        NSError *err5;
        
        NSData *jsonData5 = [NSJSONSerialization dataWithJSONObject:jsonDict5 options:kNilOptions error:&err5];
        
        NSString *str5=[[NSString alloc] initWithData:jsonData5 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
        
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str5,@"ordering_info_table",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str5);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=ordering_info_table&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str5 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str5);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            OrderinfInfoConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [OrderinfInfoConnection start];
            }
        }


        NSString *invCountSQL = [NSString stringWithFormat:@"select count(*) as totalcount from inventorytable"];
        NSMutableArray *countArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:invCountSQL resultsArray:countArray];
        ////NSLog(@"count %@",countArray);
        NSDictionary *dict=[countArray objectAtIndex:0];
        
        int inventorycount=[[dict objectForKey:@"totalcount"] intValue];
        [productPaginationObject  ResultsPerset:inventorycount];
        if (inventorycount>0)
        {
            [ResultspersetBtn setTitle:[[productPaginationObject  ResultspersetArray] objectAtIndex:0] forState:UIControlStateNormal];
        }
        
        NSString  *strp=[NSString stringWithFormat:@"%@",ResultspersetBtn.titleLabel.text];
        
        NSArray *array=[strp componentsSeparatedByString:@"-"];
        
        strp=[array objectAtIndex:0];
        //// //NSLog(@"string value %@",strp);
        int strint=[strp intValue];
        
        NSString *selectsql=[NSString stringWithFormat:@"SELECT inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id FROM inventorytable limit 50 offset %d",strint-1];
        // // //NSLog(@" seletced query %@",selectsql);
        NSMutableArray *productsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:selectsql resultsArray:productsArray];
        NSMutableArray *rdarray=productsArray;
    
   // NSMutableArray *updateTableArray3=[[NSMutableArray alloc] init];
    
    [productPaginationObject  setCompleteresultset:rdarray];
    
    [productPaginationObject   paginationinitializer:rdarray :10];
    
    [productPaginationObject  paginationsegment].tintColor=[UIColor whiteColor];
      [[productPaginationObject  paginationsegment] setFrame:CGRectMake(0,140 ,EditProductBackView.frame.size.width, 40)];
    
    [[productPaginationObject  paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
    
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [productPaginationObject  paginationsegment].selectedSegmentIndex=selectedsegindex;
    [productPaginationObject  activateResults:selectedsegindex];
    [editProductTable reloadData];
       
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"Product Data Successfully saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        modifierItem=@"no";
        CountthisItem=@"no";
        allowbuyback=@"no";
        printonreceipt=@"no";
        foodstampable=@"no";
        Promptprice=@"no";
        Productnotes=@"";
        Promptprice=@"";
        OPBarcodes=@"";
        OPBonusPoints=@"";
        OPlocation=@"";
        OPunittype=@"";
        OPunitsize=@"";
        OPCommission=@"";
        SkusArray=Nil;
        ModifierItemNosArray=nil;
        modifierNamesArray=nil;
        
        preferredsArray=nil;
        CostpersArray=nil;
        CasecostsArray=nil;
        NumberincasesArray=nil;
        VendorPartsArray=nil;
        SelectedOpVendorsArray=nil;
      
         SkusArray=[[NSMutableArray alloc]init];
        
         ModifierItemNosArray=[[NSMutableArray alloc]init];
         modifierNamesArray=[[NSMutableArray alloc]init];
        
        preferredsArray=[[NSMutableArray alloc]init];
        CostpersArray=[[NSMutableArray alloc]init];
        CasecostsArray=[[NSMutableArray alloc]init];
        NumberincasesArray=[[NSMutableArray alloc]init];
        VendorPartsArray=[[NSMutableArray alloc]init];
        SelectedOpVendorsArray=[[NSMutableArray alloc]init];

        ItemNameField.text=@"";
        ItemNumberField.text=@"";
        CostField.text=@"";
        DescriptionText.text=@"";
        InStockField.text=@"";
        PriceyouChargeField.text=@"";
        [PriceWithTaxBtn setTitle:@"" forState:UIControlStateNormal];
        CategoryDict=nil,CategoryDict2=nil,CategoryDict3=nil,CategoryDict4=nil,CategoryDict5=nil,str=nil,str2=nil,str3=nil,str4=nil,str5=nil,jsonData=nil,jsonData2=nil,jsonData3=nil,jsonData4=nil,jsonData5=nil,jsonDict=nil,jsonDict2=nil,jsonDict3=nil,jsonDict4=nil,jsonDict5=nil;
       
    }
    else
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Item Number already exist change the Item Number" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        alert=nil;
        
    }
}
-(void)SaveChangeProductData
{
    NSString *departmentstr=[NSString stringWithFormat:@"%@",ChangeDepartmentBtn.titleLabel.text];
    NSString *vendorstr=[NSString stringWithFormat:@"%@",ChangeAddpricingBtn.titleLabel.text];
    NSString *pricewithtax=[NSString stringWithFormat:@"%@",ChangePriceWithTaxBtn.titleLabel.text];
    
    NSString *tstr=[NSString stringWithFormat:@"%f",ProductTotalTax];
    
    NSString *invupdateSQL =@"UPDATE inventorytable SET inventary_department=?,inventary_item_name=?,inventary_second_description=?,inventary_avg_cost=?,inventary_price_tax=?,inventary_price_change=?,inventary_in_stock=?,inventary_taxone=?,inventary_vendor=?,inventory_total_tax=?,inventary_notes=? WHERE inventory_item_no=?";
    
    NSMutableArray *insertsArray=[[NSMutableArray alloc]initWithObjects:departmentstr,ChangeItemNameField.text,ChangeDescriptionText.text,ChangeCostField.text,pricewithtax,ChangePriceyouChargeField.text,ChangeInStockField.text,TaxValueStr,vendorstr,tstr,Productnotes,ChangeItemNumberField.text, nil];
    
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:invupdateSQL withArguments:insertsArray];
    
    //product data
    
    NSString *querySQL = [NSString stringWithFormat:@"SELECT inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id,server_local FROM inventorytable WHERE inventory_item_no='%@'",ChangeItemNumberField.text];
    NSMutableArray *productDataArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:productDataArray];
    
    NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
    [CategoryDict setObject:productDataArray forKey:@"fields"];
    NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
    
    
    NSError *err;
    
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
    
    NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"UPDATE",[generalDataObject  userID],@"saveinfo.php?",str,@"inventorytable",[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }
    else if([generalDataObject  connectedToInternet]){
        
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
            // //NSLog(@"%@",str);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=inventorytable&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            CategoryConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [CategoryConnection start];
        }
    }
    
//ordering info
    
    
    NSString *selectorderquerySQL = [NSString stringWithFormat:@"SELECT unique_id FROM ordering_info_table WHERE inventory_item_no='%@'",ChangeItemNumberField.text];
    NSMutableArray *orderuniqueArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:selectorderquerySQL resultsArray:orderuniqueArray];
    
    NSMutableArray *orderuniqueidsArray=[[NSMutableArray alloc]init];
    
    for (NSDictionary *Dict in orderuniqueArray) {
        
        [orderuniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
    }
    NSError *err8;
    
    NSData *jsonData8 = [NSJSONSerialization dataWithJSONObject:orderuniqueidsArray options:kNilOptions error:&err8];
    
    NSString *str8=[[NSString alloc] initWithData:jsonData8 encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str8,@"optional_info_table",[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }
    else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
            
            // //NSLog(@"%@",str8);
            NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=optional_info_table&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str8 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            VendorConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [VendorConnection start];
        }
    }
    
    NSString *deleteSQL2 =@"DELETE FROM ordering_info_table WHERE inventory_item_no=?";
    NSMutableArray *delteorder=[[NSMutableArray alloc]initWithObjects:ChangeItemNumberField.text, nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deleteSQL2 withArguments:delteorder];
    
    if ([SelectedOpVendorsArray count]>0)
    {
        NSString *insertSQL5;
        for (int i=0; i<[SelectedOpVendorsArray count]; i++)
        {
            
            NSString *vendorcomapnyname=[SelectedOpVendorsArray objectAtIndex:i];
            NSString *vendorno=[VendorPartsArray  objectAtIndex:i];
            NSString *casecost=[CasecostsArray objectAtIndex:i];
            NSString *costper=[CostpersArray  objectAtIndex:i];
            NSString *numberincase=[NumberincasesArray objectAtIndex:i];
            NSString *preferred=[preferredsArray  objectAtIndex:i];
            
            insertSQL5 =@"insert into ordering_info_table (venderpart_no,vendor_company_name,cost_per,case_cost,no_in_case,preferred,inventory_item_no,unique_id,created_timestamp,modified_timestamp) values(?,?,?,?,?,?,?,?,?,?)";
            
            NSMutableArray *orderArray=[[NSMutableArray alloc]initWithObjects:vendorno,vendorcomapnyname,costper,casecost,numberincase,preferred,ChangeItemNumberField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL5 withArguments:orderArray];
            
            
        }
    }
    
    NSString *orderquerySQL = [NSString stringWithFormat:@"SELECT venderpart_no,vendor_company_name,cost_per,case_cost,no_in_case,preferred,inventory_item_no,unique_id,created_timestamp,modified_timestamp,server_local FROM ordering_info_table WHERE inventory_item_no='%@'",ChangeItemNumberField.text];
    NSMutableArray *orderininfosArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:orderquerySQL resultsArray:orderininfosArray];
    
    NSMutableDictionary *CategoryDict5=[[NSMutableDictionary alloc]init];
    [CategoryDict5 setObject:orderininfosArray forKey:@"fields"];
    NSDictionary *jsonDict5= [NSDictionary dictionaryWithDictionary:CategoryDict5];
    
    
    NSError *err5;
    
    NSData *jsonData5 = [NSJSONSerialization dataWithJSONObject:jsonDict5 options:kNilOptions error:&err5];
    
    NSString *str5=[[NSString alloc] initWithData:jsonData5 encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str8,@"optional_info_table",[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }
    else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
            
            // //NSLog(@"%@",str5);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=ordering_info_table&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str5 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str5);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            OrderinfInfoConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [OrderinfInfoConnection start];
        }
    }
    
    
    //Sku data
    
    
    NSString *skuuniquequerySQL = [NSString stringWithFormat:@"SELECT unique_id FROM alternate_sku WHERE inventory_item_no='%@'",ChangeItemNumberField.text];
    NSMutableArray *uniqueskusArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:skuuniquequerySQL resultsArray:uniqueskusArray];
    
    NSMutableArray *skuuniqueidsArray=[[NSMutableArray alloc]init];
    
    for (NSDictionary *Dict in uniqueskusArray) {
        
        [skuuniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
    }
    if ([uniqueskusArray count]>0){
        NSError *err7;
        
        NSData *jsonData7 = [NSJSONSerialization dataWithJSONObject:skuuniqueidsArray options:kNilOptions error:&err7];
        
        NSString *str7=[[NSString alloc] initWithData:jsonData7 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"saveinfo.php?",str7,@"alternate_sku",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0){
                
                // //NSLog(@"%@",str7);
                NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=alternate_sku&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str7 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                
                // //NSLog(@"%@",str7);
                
                NSURL *url=[NSURL URLWithString:string];
                NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                // //NSLog(@"%@",url);
                
                [request setHTTPMethod:@"POST"];
                [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                
                
                
                SkuConnection = [NSURLConnection connectionWithRequest:request delegate:self];
                
                [SkuConnection start];
            }
        }
        NSString *updateSQL3 = [NSString stringWithFormat:@"DELETE FROM alternate_sku WHERE inventory_item_no=?"];
        
        NSMutableArray *deletesku=[[NSMutableArray alloc]initWithObjects:ChangeItemNumberField.text, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL3 withArguments:deletesku];
        
    }
    
    
    
    NSString *updateSQL;
    for (int i=0; i<[SkusArray count]; i++)
    {
        NSString *str=[SkusArray objectAtIndex:i];
        
        updateSQL =@"insert into alternate_sku (inventory_item_no, alternate_sku_value,created_timestamp,modified_timestamp) VALUES (?,?,?,?)";
        
        NSMutableArray *skusArray=[[NSMutableArray alloc]initWithObjects:ChangeItemNumberField.text,str,[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime],nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL withArguments:skusArray];
        
    }
    
    NSString *skuquerySQL = [NSString stringWithFormat:@"SELECT inventory_item_no, alternate_sku_value,created_timestamp,modified_timestamp,unique_id,server_local FROM alternate_sku WHERE inventory_item_no='%@'",ChangeItemNumberField.text];
    NSMutableArray *selectdskusArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:skuquerySQL resultsArray:selectdskusArray];
    
    NSMutableDictionary *CategoryDict3=[[NSMutableDictionary alloc]init];
    [CategoryDict3 setObject:selectdskusArray forKey:@"fields"];
    NSDictionary *jsonDict3= [NSDictionary dictionaryWithDictionary:CategoryDict3];
    
    
    NSError *err3;
    
    NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:jsonDict3 options:kNilOptions error:&err3];
    
    NSString *str3=[[NSString alloc] initWithData:jsonData3 encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str3,@"alternate_sku",[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }
    else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
            
            // //NSLog(@"%@",str3);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=alternate_sku&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str3 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str3);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            SkuConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [SkuConnection start];
        }
    }
    
    //Modifier Data
    
  
    if ([ModifierItemNosArray count]>0)
    {
        NSString *selectmodquerySQL = [NSString stringWithFormat:@"SELECT unique_id FROM modifier_table WHERE inventory_item_no='%@'",ChangeItemNumberField.text];
        NSMutableArray *uniquemodifiersArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:selectmodquerySQL resultsArray:uniquemodifiersArray];
        
        NSMutableArray *catuniqueidsArray=[[NSMutableArray alloc]init];
        
        for (NSDictionary *Dict in uniquemodifiersArray) {
            
            [catuniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }
        if ([uniquemodifiersArray count]>0)
        {
            NSError *err6;
            
            NSData *jsonData6 = [NSJSONSerialization dataWithJSONObject:catuniqueidsArray options:kNilOptions error:&err6];
            
            NSString *str6=[[NSString alloc] initWithData:jsonData6 encoding:NSUTF8StringEncoding];
            
            if(![generalDataObject  connectedToInternet]){
                
                
                NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
                NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str6,@"modifier_table",[generalDataObject getsystemDatetime], nil];
                
                [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            }
            else if([generalDataObject  connectedToInternet]){
                
                if ([[generalDataObject  OriginalbaseURLstr] length]>0)
                {
                    
                    // //NSLog(@"%@",str6);
                    NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=modifier_table&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str6 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                    
                    
                    
                    NSURL *url=[NSURL URLWithString:string];
                    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                    // //NSLog(@"%@",url);
                    
                    [request setHTTPMethod:@"POST"];
                    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                    //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                    
                    
                    
                    ModifierConnection = [NSURLConnection connectionWithRequest:request delegate:self];
                    
                    [ModifierConnection start];
                }
            }
            
            NSString *deleteupdateSQL3 =@"DELETE FROM modifier_table WHERE inventory_item_no=?";
            NSMutableArray *deltemodArray=[[NSMutableArray alloc]initWithObjects:ChangeItemNumberField.text, nil];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deleteupdateSQL3 withArguments:deltemodArray];
            
        }
        
        NSString *insertSQL2;
        for (int i=0; i<[ModifierItemNosArray count]; i++)
        {
            NSString *str=[ModifierItemNosArray objectAtIndex:i];
            NSString *name=[modifierNamesArray  objectAtIndex:i];
            
            insertSQL2 =@"insert into modifier_table (inventory_item_no, modifier_item_no,inventary_item_name,unique_id,created_timestamp,modified_timestamp) VALUES(?,?,?,?,?,?) ";
            NSMutableArray *modsArray=[[NSMutableArray alloc]initWithObjects:ChangeItemNumberField.text,str,name,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL2 withArguments:modsArray];
            
        }
    }
    
    
    NSString *modquerySQL = [NSString stringWithFormat:@"SELECT inventory_item_no, modifier_item_no,inventary_item_name,unique_id,created_timestamp,modified_timestamp,server_local FROM modifier_table WHERE inventory_item_no='%@'",ChangeItemNumberField.text];
    NSMutableArray *modifiersArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:modquerySQL resultsArray:modifiersArray];
    
    
    NSMutableDictionary *CategoryDict4=[[NSMutableDictionary alloc]init];
    [CategoryDict4 setObject:modifiersArray forKey:@"fields"];
    NSDictionary *jsonDict4= [NSDictionary dictionaryWithDictionary:CategoryDict4];
    
    
    NSError *err4;
    
    NSData *jsonData4 = [NSJSONSerialization dataWithJSONObject:jsonDict4 options:kNilOptions error:&err4];
    
    NSString *str4=[[NSString alloc] initWithData:jsonData4 encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str4,@"modifier_table",[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
    }
    else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
            
            // //NSLog(@"%@",str4);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=modifier_table&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str4 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str4);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            ModifierConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [ModifierConnection start];
        }
    }
    
//Optional info data
     Editcommission=[NSString stringWithFormat:@"%@",optCommissionBtn.titleLabel.text];
    NSString *optselectquerySQL = [NSString stringWithFormat: @"SELECT bonus_points,barcodes,location,unit_type,unit_size,commission_optional_info,inventary_modifier_item,inventary_count_this_item,inventary_prompt_quantity,inventary_prompt_price,inventary_print_on_receipt,inventary_foodstampable,inventory_item_no,unique_id,created_timestamp,modified_timestamp,server_local FROM optional_info_table WHERE inventory_item_no='%@'",ChangeItemNumberField.text];
    NSMutableArray *optionalinfoAray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:optselectquerySQL resultsArray:optionalinfoAray];
    if ([optionalinfoAray count]>0)
    {
        NSString *optupdateSQL =@"UPDATE optional_info_table SET bonus_points=?,barcodes=?,location=?,unit_size=?,unit_type=?,commission_optional_info=?,inventary_modifier_item=?,inventary_count_this_item=?,inventary_prompt_quantity=?,inventary_prompt_price=?,inventary_print_on_receipt=?,inventary_foodstampable=? WHERE inventory_item_no=?";
        
        NSMutableArray *optionalArray=[[NSMutableArray alloc]initWithObjects:Editbonuspoint,Editbarcode,Editlocation,Editunitsize,EditUnittype,Editcommission,EditmodifierItem,EditCountthisItem,Editallowbuyback,Editpromptprice,Editprintonreceipt,Editfoodstampable,ChangeItemNumberField.text, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:optupdateSQL withArguments:optionalArray];
    }
   else
   {
       NSString *optinsertSQL=@"insert into optional_info_table (bonus_points,barcodes,location,unit_type,unit_size,commission_optional_info,inventary_modifier_item,inventary_count_this_item,inventary_prompt_quantity,inventary_prompt_price,inventary_print_on_receipt,inventary_foodstampable,inventory_item_no,unique_id,created_timestamp,modified_timestamp) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
       
        NSMutableArray *optionalArray=[[NSMutableArray alloc]initWithObjects:Editbonuspoint,Editbarcode,Editlocation,Editunitsize,EditUnittype,Editcommission,EditmodifierItem,EditCountthisItem,Editallowbuyback,Editpromptprice,Editprintonreceipt,Editfoodstampable,ChangeItemNumberField.text,[generalDataObject genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
       [[DataBaseManager dataBaseManager]executeRecordsWithQuery:optinsertSQL withArguments:optionalArray];
       
   }
    
    
   
    
    
    NSString *optquerySQL = [NSString stringWithFormat: @"SELECT bonus_points,barcodes,location,unit_type,unit_size,commission_optional_info,inventary_modifier_item,inventary_count_this_item,inventary_prompt_quantity,inventary_prompt_price,inventary_print_on_receipt,inventary_foodstampable,inventory_item_no,unique_id,created_timestamp,modified_timestamp,server_local FROM optional_info_table WHERE inventory_item_no='%@'",ChangeItemNumberField.text];
    NSMutableArray *optionalinfoDataAray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:optquerySQL resultsArray:optionalinfoDataAray];
    
    NSMutableDictionary *CategoryDict2=[[NSMutableDictionary alloc]init];
    [CategoryDict2 setObject:optionalinfoDataAray forKey:@"fields"];
    NSDictionary *jsonDict2 = [NSDictionary dictionaryWithDictionary:CategoryDict2];
    
    
    NSError *err2;
    
    NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:jsonDict2 options:kNilOptions error:&err2];
    
    NSString *str2=[[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"UPDATE",[generalDataObject  userID],@"saveinfo.php?",str2,@"optional_info_table",[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }
    else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
            // //NSLog(@"%@",str2);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=optional_info_table&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str2);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            VendorConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [VendorConnection start];
        }
    }
    
    NSString *invCountSQL = [NSString stringWithFormat:@"select count(*) as totalcount from inventorytable"];
    NSMutableArray *countArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:invCountSQL resultsArray:countArray];
    ////NSLog(@"count %@",countArray);
    NSDictionary *dict=[countArray objectAtIndex:0];
    
    int inventorycount=[[dict objectForKey:@"totalcount"] intValue];
    [productPaginationObject  ResultsPerset:inventorycount];
    if (inventorycount>0)
    {
        [ResultspersetBtn setTitle:[[productPaginationObject  ResultspersetArray] objectAtIndex:0] forState:UIControlStateNormal];
    }
    
    [DisplaySettable reloadData];
    
    [ResultspersetBtn setTitle:[[productPaginationObject  ResultspersetArray] objectAtIndex:0] forState:UIControlStateNormal];
    SelectedResultsForSet=[[productPaginationObject  ResultspersetArray] objectAtIndex:0];
    
    [self ProductpaginationMetod];
    
    
    preferredsArray=nil;
    CostpersArray=nil;
    CasecostsArray=nil;
    NumberincasesArray=nil;
    VendorPartsArray=nil;
    SelectedOpVendorsArray=nil;
    
    SkusArray=Nil;
    modifierNamesArray=nil;
    ModifierItemNosArray=nil;
    
    [self editProductViewremoveMethod];
    UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"Product Data Successfully saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
    [alert show];
    
    
    [self getVendorpartnumberMethod];
    
    CategoryDict=nil,CategoryDict2=nil,CategoryDict3=nil,CategoryDict4=nil,CategoryDict5=nil,str=nil,str2=nil,str3=nil,str4=nil,str5=nil,jsonData=nil,jsonData2=nil,jsonData3=nil,jsonData4=nil,jsonData5=nil,jsonDict=nil,jsonDict2=nil,jsonDict3=nil,jsonDict4=nil,jsonDict5=nil;
    EditmodifierItem=@"no";
    EditCountthisItem=@"no";
    Editallowbuyback=@"no";
    Editprintonreceipt=@"no";
    Editfoodstampable=@"no";
    Editpromptprice=@"no";
    departmentstr=nil,vendorstr=pricewithtax=nil;
    [DisplaySettable reloadData];
}
-(void)SaveDuplicateProductData
{
    NSString *departmentstr=[NSString stringWithFormat:@"%@",DuplicateDepartmentBtn.titleLabel.text];
    NSString *vendorstr=[NSString stringWithFormat:@"%@",DuplicateAddpricingBtn.titleLabel.text];
    NSString *pricewithtax=[NSString stringWithFormat:@"%@",DuplicatePriceWithTaxBtn.titleLabel.text];
    if (!ItemNumbersArray)
        ItemNumbersArray=[[NSMutableArray alloc]init];
    NSString *querySQL = [NSString stringWithFormat: @"SELECT inventory_item_no FROM inventorytable"];
    NSMutableArray *productsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:productsArray];
    @autoreleasepool {
        for (NSDictionary *myDict in productsArray)
        {
            NSString *catname=[myDict objectForKey:@"inventory_item_no"];
            
            [ItemNumbersArray addObject:catname];
            catname=nil;
        }
    }
    
    NSString *querySQL7 = [NSString stringWithFormat:@"SELECT department_id,category_id FROM department_details"];
    NSMutableArray *deptsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:deptsArray];
    
    NSString *catdedtstr;
    for (NSDictionary *myDict in deptsArray)
    {
        
        NSString *catname=[myDict objectForKey:@"department_id"];
        if ([catname isEqualToString:departmentstr])
        {
            catdedtstr=[myDict objectForKey:@"category_id"];
        }
        catname=nil;
        
    }
    
    NSUInteger objIdx = [ItemNumbersArray containsObject:DuplicateItemNumberField.text];
    // //NSLog(@"%lu",(unsigned long)objIdx);
    if(objIdx == 0)
    {
        NSString *tstr=[NSString stringWithFormat:@"%f",ProductTotalTax];
        
        NSString *invinsertSQL =@"insert into inventorytable (inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        NSMutableArray *insertsArray=[[NSMutableArray alloc]initWithObjects:departmentstr,DuplicateItemNumberField.text,DuplicateItemNameField.text,DuplicateDescriptionText.text,DuplicateCostField.text,pricewithtax,DuplicatePriceyouChargeField.text,DuplicateInStockField.text,@"1",TaxValueStr,vendorstr,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime],tstr,Productnotes,@"true",catdedtstr, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:invinsertSQL withArguments:insertsArray];
        
        
        
        
        //Product data
        
        
        NSString *querySQL = [NSString stringWithFormat:@"SELECT inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id,server_local FROM inventorytable WHERE inventory_item_no='%@'",DuplicateItemNumberField.text];
        NSMutableArray *productDataArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:productDataArray];
        
        NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
        [CategoryDict setObject:productDataArray forKey:@"fields"];
        NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
        
        
        NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str,@"inventorytable",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
                
                // //NSLog(@"%@",str);
                NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=inventorytable&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                
                // //NSLog(@"%@",str);
                
                NSURL *url=[NSURL URLWithString:string];
                NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                // //NSLog(@"%@",url);
                
                [request setHTTPMethod:@"POST"];
                [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                
                
                
                CategoryConnection = [NSURLConnection connectionWithRequest:request delegate:self];
                
                [CategoryConnection start];
            }
        }
        //orderinginfo data
        
        if ([SelectedOpVendorsArray count]>0)
        {
            NSString *insertSQL5;
            for (int i=0; i<[SelectedOpVendorsArray count]; i++)
            {
                
                NSString *vendorcomapnyname=[SelectedOpVendorsArray objectAtIndex:i];
                NSString *vendorno=[VendorPartsArray  objectAtIndex:i];
                NSString *casecost=[CasecostsArray objectAtIndex:i];
                NSString *costper=[CostpersArray  objectAtIndex:i];
                NSString *numberincase=[NumberincasesArray objectAtIndex:i];
                NSString *preferred=[preferredsArray  objectAtIndex:i];
                
                insertSQL5 =@"insert into ordering_info_table (venderpart_no,vendor_company_name,cost_per,case_cost,no_in_case,preferred,inventory_item_no,unique_id,created_timestamp,modified_timestamp) values(?,?,?,?,?,?,?,?,?,?)";
                
                NSMutableArray *orderingArray=[[NSMutableArray alloc]initWithObjects:vendorno,vendorcomapnyname,costper,casecost,numberincase,preferred,ItemNumberField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
                [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL5 withArguments:orderingArray];
                
            }
        }
        
        
        NSString *orderquerySQL = [NSString stringWithFormat:@"SELECT venderpart_no,vendor_company_name,cost_per,case_cost,no_in_case,preferred,inventory_item_no,unique_id,created_timestamp,modified_timestamp,server_local FROM ordering_info_table WHERE inventory_item_no='%@'",ItemNumberField.text];
        NSMutableArray *orderininfosArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:orderquerySQL resultsArray:orderininfosArray];
        
        NSMutableDictionary *CategoryDict5=[[NSMutableDictionary alloc]init];
        [CategoryDict5 setObject:orderininfosArray forKey:@"fields"];
        NSDictionary *jsonDict5= [NSDictionary dictionaryWithDictionary:CategoryDict5];
        
        
        NSError *err5;
        
        NSData *jsonData5 = [NSJSONSerialization dataWithJSONObject:jsonDict5 options:kNilOptions error:&err5];
        
        NSString *str5=[[NSString alloc] initWithData:jsonData5 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str5,@"ordering_info_table",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
                
                // //NSLog(@"%@",str5);
                NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=ordering_info_table&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str5 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                
                // //NSLog(@"%@",str5);
                
                NSURL *url=[NSURL URLWithString:string];
                NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                // //NSLog(@"%@",url);
                
                [request setHTTPMethod:@"POST"];
                [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                
                
                
                OrderinfInfoConnection = [NSURLConnection connectionWithRequest:request delegate:self];
                
                [OrderinfInfoConnection start];
            }
        }
        
        
        //// //NSLog(@" Vendor part numbers %@",VendorpartNosArray);
        //optional info data
        
        
        Editcommission=[NSString stringWithFormat:@"%@",optCommissionBtn.titleLabel.text];
        
        NSString *optinsertSQL=@"insert into optional_info_table (bonus_points,barcodes,location,unit_type,unit_size,commission_optional_info,inventary_modifier_item,inventary_count_this_item,inventary_prompt_quantity,inventary_prompt_price,inventary_print_on_receipt,inventary_foodstampable,inventory_item_no,unique_id,created_timestamp,modified_timestamp) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        NSMutableArray *optionalArray=[[NSMutableArray alloc]initWithObjects:Editbonuspoint,Editbarcode,Editlocation,EditUnittype,Editunitsize,Editcommission,EditmodifierItem,EditCountthisItem,Editallowbuyback,Editpromptprice,Editprintonreceipt,Editfoodstampable,DuplicateItemNumberField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject Datestring], nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:optinsertSQL withArguments:optionalArray];
        
        NSString *optquerySQL = [NSString stringWithFormat: @"SELECT bonus_points,barcodes,location,unit_type,unit_size,commission_optional_info,inventary_modifier_item,inventary_count_this_item,inventary_prompt_quantity,inventary_prompt_price,inventary_print_on_receipt,inventary_foodstampable,inventory_item_no,unique_id,created_timestamp,modified_timestamp,server_local FROM optional_info_table WHERE inventory_item_no='%@'",DuplicateItemNumberField.text];
        NSMutableArray *optionalinfoDataAray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:optquerySQL resultsArray:optionalinfoDataAray];
        
        NSMutableDictionary *CategoryDict2=[[NSMutableDictionary alloc]init];
        [CategoryDict2 setObject:optionalinfoDataAray forKey:@"fields"];        NSDictionary *jsonDict2 = [NSDictionary dictionaryWithDictionary:CategoryDict2];
        
        
        NSError *err2;
        
        NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:jsonDict2 options:kNilOptions error:&err2];
        
        NSString *str2=[[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str2,@"optional_info_table",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
                // //NSLog(@"%@",str2);
                NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=optional_info_table&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                
                // //NSLog(@"%@",str2);
                
                NSURL *url=[NSURL URLWithString:string];
                NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                // //NSLog(@"%@",url);
                
                [request setHTTPMethod:@"POST"];
                [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                
                
                
                VendorConnection = [NSURLConnection connectionWithRequest:request delegate:self];
                
                [VendorConnection start];
            }
        }
        
        //Sku data
        
        NSString *insertSQL;
        if ([SkusArray count]>0)
        {
            for (int i=0; i<[SkusArray count]; i++)
            {
                NSString *str=[SkusArray objectAtIndex:i];
                
                insertSQL = @"insert into alternate_sku (inventory_item_no, alternate_sku_value,created_timestamp,modified_timestamp,unique_id) VALUES (?,?,?,?,?)";
                NSMutableArray *skusArray=[[NSMutableArray alloc]initWithObjects:ItemNumberField.text,str,[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime],[generalDataObject  genRandStringLength:20], nil];
                
                [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:skusArray];
                insertSQL=nil;
                // //NSLog(@"%@",insertSQL);
            }
        }
        
        NSString *skuquerySQL = [NSString stringWithFormat:@"SELECT inventory_item_no, alternate_sku_value,created_timestamp,modified_timestamp,unique_id,server_local FROM alternate_sku WHERE inventory_item_no='%@'",DuplicateItemNumberField.text];
        NSMutableArray *selectdskusArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:skuquerySQL resultsArray:selectdskusArray];
        
        NSMutableDictionary *CategoryDict3=[[NSMutableDictionary alloc]init];
        [CategoryDict3 setObject:selectdskusArray forKey:@"fields"];
        NSDictionary *jsonDict3= [NSDictionary dictionaryWithDictionary:CategoryDict3];
        
        
        NSError *err3;
        
        NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:jsonDict3 options:kNilOptions error:&err3];
        
        NSString *str3=[[NSString alloc] initWithData:jsonData3 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str3,@"alternate_sku",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
                
                // //NSLog(@"%@",str3);
                NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=alternate_sku&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str3 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                
                // //NSLog(@"%@",str3);
                
                NSURL *url=[NSURL URLWithString:string];
                NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                // //NSLog(@"%@",url);
                
                [request setHTTPMethod:@"POST"];
                [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                
                
                
                SkuConnection = [NSURLConnection connectionWithRequest:request delegate:self];
                
                [SkuConnection start];
            }
        }
        
        
        //modifier data
        
        
        if ([ModifierItemNosArray count]>0)
        {
            NSString *insertSQL2;
            for (int i=0; i<[ModifierItemNosArray count]; i++)
            {
                NSString *str=[ModifierItemNosArray objectAtIndex:i];
                NSString *name=[modifierNamesArray  objectAtIndex:i];
                
                insertSQL2 =@"insert into modifier_table (inventory_item_no, modifier_item_no,inventary_item_name,unique_id,created_timestamp,modified_timestamp) VALUES(?,?,?,?,?,?) ";
                NSMutableArray *modsArray=[[NSMutableArray alloc]initWithObjects:ItemNumberField.text,str,name,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
                [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL2 withArguments:modsArray];
                // //NSLog(@"%@",insertSQL2);
            }
        }
        
        
        NSString *modquerySQL = [NSString stringWithFormat:@"SELECT inventory_item_no, modifier_item_no,inventary_item_name,unique_id,created_timestamp,modified_timestamp,server_local FROM modifier_table WHERE inventory_item_no='%@'",ItemNumberField.text];
        NSMutableArray *modifiersArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:modquerySQL resultsArray:modifiersArray];
        
        NSMutableDictionary *CategoryDict4=[[NSMutableDictionary alloc]init];
        [CategoryDict4 setObject:modifiersArray forKey:@"fields"];
        NSDictionary *jsonDict4= [NSDictionary dictionaryWithDictionary:CategoryDict4];
        
        
        NSError *err4;
        
        NSData *jsonData4 = [NSJSONSerialization dataWithJSONObject:jsonDict4 options:kNilOptions error:&err4];
        
        NSString *str4=[[NSString alloc] initWithData:jsonData4 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str4,@"modifier_table",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
                // //NSLog(@"%@",str4);
                NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=modifier_table&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str4 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                
                // //NSLog(@"%@",str4);
                
                NSURL *url=[NSURL URLWithString:string];
                NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                // //NSLog(@"%@",url);
                
                [request setHTTPMethod:@"POST"];
                [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                
                
                
                ModifierConnection = [NSURLConnection connectionWithRequest:request delegate:self];
                
                [ModifierConnection start];
            }
        }
        
        
        
        NSString *invCountSQL = [NSString stringWithFormat:@"select count(*) as totalcount from inventorytable"];
        NSMutableArray *countArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:invCountSQL resultsArray:countArray];
        ////NSLog(@"count %@",countArray);
        NSDictionary *dict=[countArray objectAtIndex:0];
        
        int inventorycount=[[dict objectForKey:@"totalcount"] intValue];
        [productPaginationObject  ResultsPerset:inventorycount];
        
        if (inventorycount>0)
        {
            [ResultspersetBtn setTitle:[[productPaginationObject  ResultspersetArray] objectAtIndex:0] forState:UIControlStateNormal];
        }
        
        
        [productPaginationObject  ResultspersetArray];
        
        [DisplaySettable reloadData];
        [ResultspersetBtn setTitle:[[productPaginationObject  ResultspersetArray] objectAtIndex:0] forState:UIControlStateNormal];
        
        SelectedResultsForSet=[[productPaginationObject  ResultspersetArray] objectAtIndex:0];
        
        [self ProductpaginationMetod];
        
        preferredsArray=nil;
        CostpersArray=nil;
        CasecostsArray=nil;
        NumberincasesArray=nil;
        VendorPartsArray=nil;
        SelectedOpVendorsArray=nil;
        
        [self duplicateProductViewremove];
        
        /* Editpromptprice=@"NO";
         EditCountthisItem=@"NO";
         EditmodifierItem=@"NO";
         Editallowbuyback=@"NO";
         Editfoodstampable=@"NO";
         Editpromptprice=@"NO";
         DuplicateproductNotes=@"";*/
        SkusArray=Nil;
        ModifierItemNosArray=nil;
        modifierNamesArray=nil;
        
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"Product Data Successfully saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        CategoryDict=nil,CategoryDict2=nil,CategoryDict3=nil,CategoryDict4=nil,CategoryDict5=nil,str=nil,str2=nil,str3=nil,str4=nil,str5=nil,jsonData=nil,jsonData2=nil,jsonData3=nil,jsonData4=nil,jsonData5=nil,jsonDict=nil,jsonDict2=nil,jsonDict3=nil,jsonDict4=nil,jsonDict5=nil;
        
    }
    else
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Item Number already exist change the Item Number" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        alert=nil;
        
    }
    
    EditmodifierItem=@"no";
    EditCountthisItem=@"no";
    Editallowbuyback=@"no";
    Editprintonreceipt=@"no";
    Editfoodstampable=@"no";
    Editpromptprice=@"no";
    
    
    [self getVendorpartnumberMethod];
    departmentstr=nil,vendorstr=pricewithtax=nil;
}
-(void)SaveInstantPO
{
   
    
    NSString *updateSQL =@"UPDATE inventorytable SET inventary_in_stock=? WHERE inventory_item_no=?";
    NSMutableArray *updateArray=[[NSMutableArray alloc]initWithObjects:InstantpoField.text,InvItemNumber, nil];
    
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL withArguments:updateArray];
    
    
    NSString *querySQL = [NSString stringWithFormat:@"SELECT inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id,server_local FROM inventorytable WHERE inventory_item_no='%@'",InvItemNumber];
    
    NSMutableArray *productArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:productArray];
    
    NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
    [CategoryDict setObject:productArray forKey:@"fields"];
    NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
    
    
    NSError *err;
    
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
    
    NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"UPDATE",[generalDataObject  userID],@"saveinfo.php?",str,@"inventorytable",[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }
    else if([generalDataObject  connectedToInternet]){
        
        
        
        // //NSLog(@"%@",str);
        NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=inventorytable&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        // //NSLog(@"%@",str);
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
        // //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        
        
        
        CategoryConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [CategoryConnection start];
        request=nil,url=nil,string=nil;
    }
    
    
    
    NSString *invCountSQL = [NSString stringWithFormat:@"select count(*) as totalcount from inventorytable"];
    NSMutableArray *countArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:invCountSQL resultsArray:countArray];
    ////NSLog(@"count %@",countArray);
    NSDictionary *dict=[countArray objectAtIndex:0];
    
    int inventorycount=[[dict objectForKey:@"totalcount"] intValue];
    [productPaginationObject  ResultsPerset:inventorycount];
    if (inventorycount>0)
    {
        [ResultspersetBtn setTitle:[[productPaginationObject  ResultspersetArray] objectAtIndex:0] forState:UIControlStateNormal];
    }
    
    
    NSString  *strp=[NSString stringWithFormat:@"%@",ResultspersetBtn.titleLabel.text];
    
    NSArray *array=[strp componentsSeparatedByString:@"-"];
    [DisplaySettable reloadData];
    
    strp=[array objectAtIndex:0];
    //// //NSLog(@"string value %@",strp);
    int str2=[strp intValue];
    
    NSString *selectsql=[NSString stringWithFormat:@"SELECT inventary_department,inventory_item_no,inventary_item_name,inventary_second_description,inventary_avg_cost,inventary_price_tax,inventary_price_change,inventary_in_stock,inventary_quantity,inventary_taxone,inventary_vendor,unique_id,created_timestamp,modified_timestamp,inventory_total_tax,inventary_notes,check_value,category_id FROM inventorytable limit 50 offset %d",str2-1];
    // // //NSLog(@" seletced query %@",selectsql);
    NSMutableArray *productsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:selectsql resultsArray:productsArray];
    NSMutableArray *rdarray=productsArray;
    
    //NSMutableArray *updateTableArray3=[[NSMutableArray alloc] init];
    
    [productPaginationObject  setCompleteresultset:rdarray];
    
    [productPaginationObject   paginationinitializer:rdarray :10];
    
    [productPaginationObject  paginationsegment].tintColor=[UIColor whiteColor];
    [[productPaginationObject  paginationsegment] setFrame:CGRectMake(0,140 ,EditProductBackView.frame.size.width, 40)];
    
    [[productPaginationObject  paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
    
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [productPaginationObject  paginationsegment].selectedSegmentIndex=selectedsegindex;
    [productPaginationObject  activateResults:selectedsegindex];
    [EditProductBackView addSubview:[productPaginationObject  paginationsegment]];
      [editProductTable reloadData];
    [self viewProductViewremove];
  
    
    UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"Update Instock Successfully" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
    [alert show];
    alert=nil;
    CategoryDict=nil,jsonData=nil,jsonDict=nil,str=nil;
    
}
-(void)CancelProductData
{
    ItemNameField.text=@"";
    ItemNumberField.text=@"";
    CostField.text=@"";
    DescriptionText.text=@"";
    InStockField.text=@"";
    PriceyouChargeField.text=@"";
    [PriceWithTaxBtn setTitle:@"" forState:UIControlStateNormal];
    
}
-(void)AddpricingClicked
{
    if (VendorsTable.hidden==1)
    {
        InStockField.hidden=YES;
        PriceWithTaxBtn.hidden=YES;
        VendorsTable.hidden=NO;
        
    }
    else if (VendorsTable.hidden==0)
    {
        InStockField.hidden=NO;
        PriceWithTaxBtn.hidden=NO;
        [VendorsTable setHidden:YES];
        
    }
    
}
-(void)DepartmentBtnClicked
{
    if (DepartmentsTable.hidden==1)
    {
        ItemNameField.hidden=YES;
        ItemNumberField.hidden=YES;
        DepartmentsTable.hidden=NO;

    }
    else if (DepartmentsTable.hidden==0)
    {
        ItemNameField.hidden=NO;
        ItemNumberField.hidden=NO;
        [DepartmentsTable setHidden:YES];
        
    }
    
}

-(void)getVendorpartnumberMethod
{
    if (!ItemNumbersArray)
    ItemNumbersArray=[[NSMutableArray alloc]init];
    
    NSString *querySQL = [NSString stringWithFormat:@"SELECT inventory_item_no FROM inventorytable"];
    NSMutableArray *productDataArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:productDataArray];
    for (NSDictionary *myDict in productDataArray)
    {
        
        [ItemNumbersArray addObject:[myDict objectForKey:@"inventory_item_no"]];
        
    }
    if (!VendorpartNosArray)
    VendorpartNosArray=[[NSMutableArray alloc]init];
    NSString *querySQL2;
    if ([ItemNumbersArray count]>0){
        
        for (int i=0; i<[ItemNumbersArray count]; i++)
        {
            NSString *ProductNumber=[ItemNumbersArray objectAtIndex:i];
            querySQL2 = [NSString stringWithFormat: @"SELECT venderpart_no FROM ordering_info_table WHERE inventory_item_no='%@' AND preferred='%@'",ProductNumber,@"True"];
            
            NSMutableArray *vendorArray=[[NSMutableArray alloc]init];
            [[DataBaseManager dataBaseManager]execute:querySQL2 resultsArray:vendorArray];
            
            if ([vendorArray count]>0)
            {    NSDictionary *dict=[vendorArray objectAtIndex:0];
                [VendorpartNosArray addObject:[dict objectForKey:@"venderpart_no"]];
            }
            else
            {
                [VendorpartNosArray addObject:@""];
            }
        }
        
    }
}
-(void)productRelatedDataMethod
{
  
        ProductDepartmentsArray=[[NSMutableArray alloc]init];
        ItemNumbersArray=[[NSMutableArray alloc]init];
        ItemnameArray=[[NSMutableArray alloc]init];
        productDesArray=[[NSMutableArray alloc]init];
        CostArray=[[NSMutableArray alloc]init];
        priceyouchargeArray=[[NSMutableArray alloc]init];
        pricewithTaxArray=[[NSMutableArray alloc]init];
        InstockArray=[[NSMutableArray alloc]init];
        productVendorsArray=[[NSMutableArray alloc]init];
        taxvaluesArray=[[NSMutableArray alloc]init];
        productNotesArray=[[NSMutableArray alloc]init];
   
  
    @autoreleasepool {
        for (NSDictionary *myDict in [productPaginationObject  activeresultset])
        {
            
            [ProductDepartmentsArray addObject:[myDict objectForKey:@"inventary_department"]];
            [ItemNumbersArray addObject:[myDict objectForKey:@"inventory_item_no"]];
            [productDesArray addObject:[myDict objectForKey:@"inventary_second_description"]];
            [CostArray addObject:[myDict objectForKey:@"inventary_avg_cost"]];
            [priceyouchargeArray addObject:[myDict objectForKey:@"inventary_price_change"]];
            [pricewithTaxArray addObject:[myDict objectForKey:@"inventary_price_tax"]];
            [InstockArray addObject:[myDict objectForKey:@"inventary_in_stock"]];
            [productVendorsArray addObject:[myDict objectForKey:@"inventary_vendor"]];
            [taxvaluesArray addObject:[myDict objectForKey:@"inventary_taxone"]];
            [productNotesArray addObject:[myDict objectForKey:@"inventary_notes"]];
            [ItemnameArray addObject:[myDict objectForKey:@"inventary_item_name"]];
            
            
        }
    }
    
   
}

-(void)GeneralinfoFieldClicked:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    if (selected == 100)
    {
        
        vendorNO=sender.text;
    }
    if (selected == 101)
    {
        Terms=sender.text;
    }
    if (selected == 102)
    {
        minimumOrder=sender.text;
    }
    if (selected == 103)
    {
        
        commission=sender.text;
    }
    if (selected == 104)
    {
        
        Companyname=sender.text;
    }
    if (selected == 105)
    {
        FlatRent=sender.text;
    }
    if (selected == 106)
    {
        TaxtID=sender.text;
    }
    if (selected == 107)
    {
        
        Billable=sender.text;
    }
    if (selected == 108)
    {
        
        Socialsecurity=sender.text;
    }
  
}
-(void)AddressFieldClicked:(UITextField *)sender
{
    
     NSInteger selected=sender.tag;
    
    if (selected == 100)
    {
        
        streetAddress=sender.text;
    }
    if (selected == 101)
    {
        ExtendedAddress=sender.text;
    }
    if (selected == 102)
    {
        City=sender.text;
    }
    if (selected == 103)
    {
        
        state=sender.text;
    }
    if (selected == 104)
    {
        
        Zipcode=sender.text;
    }
    if (selected == 105)
    {
        country=sender.text;
    }
    if (selected == 106)
    {
        firstname=sender.text;
    }
    if (selected == 107)
    {
        
        lastname=sender.text;
    }
    if (selected == 108)
    {
        
        phNUmber=sender.text;
    }
    if (selected == 109)
    {
        faxnumber=sender.text;
    }
    if (selected == 110)
    {
        
        email=sender.text;
    }
    if (selected == 111)
    {
        
        website=sender.text;
    }
}


-(void)DeptprinterClicked
{
    if (PrinterslistTable.hidden==1)
    {
        
        PrinterslistTable.hidden=NO;
        
        deptDestextView.hidden=YES;
    }
    else if (PrinterslistTable.hidden==0)
    {
        [PrinterslistTable setHidden:YES];
        deptDestextView.hidden=NO;
        
    }
}
-(void)SecsBtnClicked
{
    if (SecslistTable.hidden==1)
    {
        
        SecslistTable.hidden=NO;
        
      
    }
    else if (SecslistTable.hidden==0)
    {
        [SecslistTable setHidden:YES];
       
        
    }
}
-(void)EditminitsBtnClicked
{
    if (ChangeMinitslistTable.hidden==1)
    {
        
        ChangeMinitslistTable.hidden=NO;
        
        Changecanceldeptbtn.hidden=YES;
    }
    else if (ChangeMinitslistTable.hidden==0)
    {
        [ChangeMinitslistTable setHidden:YES];
        Changecanceldeptbtn.hidden=NO;
        
    }
}
-(void)DuplicateSecsBtnClicked
{
    if (DuplicateSecslistTable.hidden==1)
    {
        
        DuplicateSecslistTable.hidden=NO;
        
        
    }
    else if (DuplicateSecslistTable.hidden==0)
    {
        [DuplicateSecslistTable setHidden:YES];
        
        
    }
}
-(void)DuplicateminitsBtnClicked
{
    if (DuplicateMinitslistTable.hidden==1)
    {
        
        DuplicateMinitslistTable.hidden=NO;
        
        Duplicatecanceldeptbtn.hidden=YES;
    }
    else if (DuplicateMinitslistTable.hidden==0)
    {
        [DuplicateMinitslistTable setHidden:YES];
        Duplicatecanceldeptbtn.hidden=NO;
        
    }
}
-(void)EditSecsBtnClicked
{
    if (ChangeSecslistTable.hidden==1)
    {
        
        ChangeSecslistTable.hidden=NO;
        
        
    }
    else if (ChangeSecslistTable.hidden==0)
    {
        [ChangeSecslistTable setHidden:YES];
        
        
    }
}
-(void)minitsBtnClicked
{
    if (MinitslistTable.hidden==1)
    {
        
        MinitslistTable.hidden=NO;
        
        canceldeptbtn.hidden=YES;
    }
    else if (MinitslistTable.hidden==0)
    {
        [MinitslistTable setHidden:YES];
        canceldeptbtn.hidden=NO;
        
    }
}
-(void)FoodstampableClicked
{
    if (DeptfoodstampleBtn.selected)
    {
        [DeptfoodstampleBtn setSelected:NO];
        Deptfoodstampable=@"no";
    }
    else if(!DeptfoodstampleBtn.selected)
    {
        [DeptfoodstampleBtn setSelected:YES];
         Deptfoodstampable=@"yes";
    }
    
}
-(void)DeptTax1Clicked
{
    if (Deptax1Btn.selected)
    {
        [Deptax1Btn setSelected:NO];
        
    }
    else if(!Deptax1Btn.selected)
    {
        [Deptax1Btn setSelected:YES];
        
    }
    [self DeptTotaltaxmethod];
}
-(void)DeptTax2Clikced
{
    if (Deptax2Btn.selected)
    {
        [Deptax2Btn setSelected:NO];
        
    }
    else if(!Deptax2Btn.selected)
    {
        [Deptax2Btn setSelected:YES];
        
    }
    [self DeptTotaltaxmethod];
}
-(void)DeptTax3Clicked
{
    if (Deptax3Btn.selected)
    {
        [Deptax3Btn setSelected:NO];
        
    }
    else if(!Deptax3Btn.selected)
    {
        [Deptax3Btn setSelected:YES];
        
    }
    [self DeptTotaltaxmethod];
}
-(void)DeptBarBtnClicked
{
    if (DepBarTaxBtn.selected)
    {
        [DepBarTaxBtn setSelected:NO];
        
    }
    else if(!DepBarTaxBtn.selected)
    {
        [DepBarTaxBtn setSelected:YES];
        
    }
    [self DeptTotaltaxmethod];
}
-(void)DeptTotaltaxmethod
{
    if (DepBarTaxBtn.selected || !Deptax1Btn.selected )
    {
       
        DepTaxValueStr=@"Bartax";
       
    }
    if (Deptax1Btn.selected)
    {
        
        DepTaxValueStr=tax1Name;
      
        
    }
    if (Deptax2Btn.selected)
    {
      
        DepTaxValueStr=tax2Name;
        
        
    }
    if (Deptax3Btn.selected)
    {
       
        DepTaxValueStr=tax3Name;
       
        
    }
    if (Deptax1Btn.selected && Deptax2Btn.selected)
    {
       
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name, nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
        
        [taxesArray removeAllObjects],taxesArray=nil;
    }
    
    if (Deptax1Btn.selected  && Deptax3Btn.selected)
    {
       
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax3Name, nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
        [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (Deptax2Btn.selected  && Deptax3Btn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,tax3Name, nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
      [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (Deptax1Btn.selected && Deptax2Btn.selected && Deptax3Btn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,tax3Name, nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
       [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (Deptax1Btn.selected && DepBarTaxBtn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
       [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (Deptax2Btn.selected && DepBarTaxBtn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
        [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (Deptax3Btn.selected && DepBarTaxBtn.selected)
    {
     
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax3Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
        [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (Deptax1Btn.selected && Deptax2Btn.selected && DepBarTaxBtn.selected)
    {
      
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
        [taxesArray removeAllObjects],taxesArray=nil;
    }
    
    if (Deptax1Btn.selected  && Deptax3Btn.selected && DepBarTaxBtn.selected)
    {
       
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax3Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
        [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (Deptax2Btn.selected  && Deptax3Btn.selected && DepBarTaxBtn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,tax3Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
        [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (Deptax1Btn.selected && Deptax2Btn.selected && Deptax3Btn.selected && DepBarTaxBtn.selected)
    {
       
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,tax3Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
        [taxesArray removeAllObjects],taxesArray=nil;
        
    }
    if (!Deptax1Btn.selected && !Deptax2Btn.selected && !Deptax3Btn.selected && !DepBarTaxBtn.selected)
    {
        DepTaxValueStr=@"";
    }
}


-(void)DeptDataMethod
{
    
        DepartmentNamesArray=[[NSMutableArray alloc]init];
        departmentIDsArray=[[NSMutableArray alloc]init];
        DepartmentDesArray=[[NSMutableArray alloc]init];
        DeptCatIdsArray=[[NSMutableArray alloc]init];
        deptfoodsArray=[[NSMutableArray alloc]init];
        depttaxesArray=[[NSMutableArray alloc]init];
   
    @autoreleasepool {
        for (NSDictionary *myDict in [jobpaginationObject activeresultset])
        {
            [DepartmentDesArray addObject:[myDict objectForKey:@"department_description"]];
            [DepartmentNamesArray addObject:[myDict objectForKey:@"department_id"]];
            [DeptCatIdsArray addObject:[myDict objectForKey:@"category_id"]];
            // [deptprintersArray addObject:[myDict objectForKey:@"department_printer"]];
            [deptfoodsArray addObject:[myDict objectForKey:@"department_foodstampable"]];
            [depttaxesArray addObject:[myDict objectForKey:@"department_totaltax"]];
        }

    }
    
 
}

-(void)vendordataMethod
{
    
        VendornumbersArray=[[NSMutableArray alloc]init];
        termsArray=[[NSMutableArray alloc]init];
        minimumorderArray=[[NSMutableArray alloc]init];
        commissionsArray=[[NSMutableArray alloc]init];
        companyNAmesArray=[[NSMutableArray alloc]init];
        flatrentsArray=[[NSMutableArray alloc]init];
        TaxidsArray=[[NSMutableArray alloc]init];
        billablesArray=[[NSMutableArray alloc]init];
        socialsArray=[[NSMutableArray alloc]init];
        podeliverysArray=[[NSMutableArray alloc]init];
        streetaddressArray=[[NSMutableArray alloc]init];
        exteddedArray=[[NSMutableArray alloc]init];
        citysArray=[[NSMutableArray alloc]init];
        statesArray=[[NSMutableArray alloc]init];
        ZipcodesArray=[[NSMutableArray alloc]init];
        countrysArray=[[NSMutableArray alloc]init];
        firstnamesArray=[[NSMutableArray alloc]init];
        lastnamesArray=[[NSMutableArray alloc]init];
        phnumbersArray=[[NSMutableArray alloc]init];
        faxesArray=[[NSMutableArray alloc]init];
        emailsArray=[[NSMutableArray alloc]init];
        websitesArray=[[NSMutableArray alloc]init];
   

    @autoreleasepool {
        for (NSDictionary *myDict in [vendorPaginationObject activeresultset])
        {
            // NSString *vendorno=[myDict objectForKey:@"vendor_no"];
            [VendornumbersArray addObject:[myDict objectForKey:@"vendor_no"]];
            [termsArray addObject:[myDict objectForKey:@"vendor_terms"]];
            [minimumorderArray addObject:[myDict objectForKey:@"vendor_min_order"]];
            [commissionsArray addObject:[myDict objectForKey:@"vendor_commission_percent"]];
            [companyNAmesArray addObject:[myDict objectForKey:@"vendor_company_name"]];
            [flatrentsArray addObject:[myDict objectForKey:@"vendor_flat_rent_rate"]];
            [TaxidsArray addObject:[myDict objectForKey:@"vendor_tax_id"]];
            [billablesArray addObject:[myDict objectForKey:@"vendor_billable_department"]];
            [socialsArray addObject:[myDict objectForKey:@"vendor_social_security_no"]];
            [podeliverysArray addObject:[myDict objectForKey:@"vendor_po_delivery_method"]];
            [streetaddressArray addObject:[myDict objectForKey:@"vendor_street_address"]];
            [exteddedArray addObject:[myDict objectForKey:@"vendor_extended_address"]];
            [citysArray addObject:[myDict objectForKey:@"vendor_city"]];
            [statesArray  addObject:[myDict objectForKey:@"vendor_state"]];
            [ZipcodesArray addObject:[myDict objectForKey:@"vendor_zip_code"]];
            [countrysArray addObject:[myDict objectForKey:@"vendor_country"]];
            [firstnamesArray addObject:[myDict objectForKey:@"vendor_first_name"]];
            [lastnamesArray addObject:[myDict objectForKey:@"vendor_last_name"]];
            [phnumbersArray addObject:[myDict objectForKey:@"vendor_telephone_number"]];
            [faxesArray addObject:[myDict objectForKey:@"vendor_fax_number"]];
            [emailsArray addObject:[myDict objectForKey:@"vendor_email"]];
            [websitesArray addObject:[myDict objectForKey:@"vendor_website"]];
            
        }

    }
    
   
}
-(void)DeliveryMethodbtnClicked
{
    
    if (DeliveryTypesTable.hidden==1)
    {
        
        DeliveryTypesTable.hidden=NO;
        
       
    }
    else if (DeliveryTypesTable.hidden==0)
    {
        [DeliveryTypesTable setHidden:YES];
        
    }
}
-(void)CategoryforthisDept
{
    if (categorysListTable.hidden==1)
    {
        
        categorysListTable.hidden=NO;
        
        IDfield.hidden=YES;
    }
    else if (categorysListTable.hidden==0)
    {
        [categorysListTable setHidden:YES];
         IDfield.hidden=NO;
    
    }
}
#pragma mark - save vendor data method
-(void)SaveVendorData
{
    if (!VendornumbersArray)
    VendornumbersArray=[[NSMutableArray alloc]init];
    
     NSString *querySQL = [NSString stringWithFormat: @"SELECT vendor_no FROM vendor"];
    NSMutableArray *vendorsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:vendorsArray];
    for (NSDictionary *myDict in vendorsArray)
    {
        NSString *catname=[myDict objectForKey:@"vendor_no"];
        
        [VendornumbersArray addObject:catname];
        
    }
    
    NSUInteger objIdx = [VendornumbersArray containsObject:vendorNO];
   // // //NSLog(@"%lu",(unsigned long)objIdx);
    if(objIdx == 0)
    {
        //// //NSLog(@"condition true");
         NSString *Deliverytype=@"";
      Deliverytype=[NSString stringWithFormat:@"%@", DeliverymethodBtn.titleLabel.text];
    NSString *uniqueid=[generalDataObject  genRandStringLength:20];
        
    NSString *insertSQL =@"insert into vendor (vendor_no,vendor_terms,vendor_min_order,vendor_commission_percent,vendor_company_name,vendor_flat_rent_rate,vendor_tax_id,vendor_billable_department,vendor_social_security_no,vendor_po_delivery_method,vendor_street_address,vendor_extended_address,vendor_city,vendor_state,vendor_zip_code,vendor_country,vendor_first_name,vendor_last_name,vendor_telephone_number,vendor_fax_number,vendor_email,vendor_website,unique_id,created_timestamp,modified_timestamp) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        NSMutableArray *insertVDataArray=[[NSMutableArray alloc]initWithObjects:vendorNO,Terms,minimumOrder,commission,Companyname,FlatRent,TaxtID,Billable,Socialsecurity,Deliverytype,streetAddress,ExtendedAddress,City,state,Zipcode,country,firstname,lastname,phNUmber,faxnumber,email,website,uniqueid,[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:insertVDataArray];
        
        
        NSString *querySQL = [NSString stringWithFormat:@"SELECT vendor_no,vendor_terms,vendor_min_order,vendor_commission_percent,vendor_company_name,vendor_flat_rent_rate,vendor_tax_id,vendor_billable_department,vendor_social_security_no,vendor_po_delivery_method,vendor_street_address,vendor_extended_address,vendor_city,vendor_state,vendor_zip_code,vendor_country,vendor_first_name,vendor_last_name,vendor_telephone_number,vendor_fax_number,vendor_email,vendor_website FROM vendor"];
        NSMutableArray *vendorsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:vendorsArray];
        
        NSMutableArray *rdarray=vendorsArray;
        
        [vendorPaginationObject  paginationinitializer:rdarray :6];
        
        [vendorPaginationObject paginationsegment].tintColor=[UIColor whiteColor];
        [[vendorPaginationObject paginationsegment] setFrame:CGRectMake(5, AddvendorBtn.frame.size.height+10,vendorsView.frame.size.width-10, 40)];
        
        [[vendorPaginationObject paginationsegment] addTarget:self action:@selector(segmentchanged3:) forControlEvents:UIControlEventValueChanged];
        
        NSInteger selectedsegindex;
        selectedsegindex=0;
        [vendorPaginationObject paginationsegment].selectedSegmentIndex=selectedsegindex;
       [vendorPaginationObject activateResults:selectedsegindex];
    
       [EditVendorTable reloadData];
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"vendor Data Successfully saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        
    
       NSString *selectquerySQL = [NSString stringWithFormat:@"SELECT vendor_no,vendor_terms,vendor_min_order,vendor_commission_percent,vendor_company_name,vendor_flat_rent_rate,vendor_tax_id,vendor_billable_department,vendor_social_security_no,vendor_po_delivery_method,vendor_street_address,vendor_extended_address,vendor_city,vendor_state,vendor_zip_code,vendor_country,vendor_first_name,vendor_last_name,vendor_telephone_number,vendor_fax_number,vendor_email,vendor_website,unique_id,created_timestamp,modified_timestamp,server_local FROM vendor WHERE vendor_no='%@'",vendorNO];
        NSMutableArray *selectVendorsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:selectquerySQL resultsArray:selectVendorsArray];
        
        NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
        [CategoryDict setObject:selectVendorsArray forKey:@"fields"];
        NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
        
        
        NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  if(![generalDataObject  connectedToInternet]){
    
    NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
    NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str,@"vendor",[generalDataObject getsystemDatetime], nil];
    
    [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];

    
    
        }
else if([generalDataObject  connectedToInternet]){
    
    if ([[generalDataObject  OriginalbaseURLstr] length]>0)
    {
        //// //NSLog(@"%@",str);
        NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=vendor&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        //// //NSLog(@"%@",str);
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
       // // //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        
        
        
        VendorConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [VendorConnection start];
        string=nil,request=nil,url=nil;
    }
        }
        
        Deliverytype=nil,uniqueid=nil,CategoryDict=nil,jsonData=nil,jsonDict=nil,str=nil;
    }
    else
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Vendor ID already exist change the Vendor id" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        alert=nil;
    }

      vendorNO=Terms=minimumOrder=commission=Companyname=FlatRent=TaxtID=Billable=Socialsecurity=streetAddress=ExtendedAddress=City=state=Zipcode=country=firstname=lastname=phNUmber=faxnumber=email=website=@"";
}
-(void)SaveChnageVendorData
{
    
    NSString *POstr=[NSString stringWithFormat:@"%@", changeDeliverymethodBtn.titleLabel.text];
    if (!VendornumbersArray)
        VendornumbersArray=[[NSMutableArray alloc]init];
    NSString *querySQL = [NSString stringWithFormat: @"SELECT vendor_no FROM vendor"];
    NSMutableArray *vendorsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:vendorsArray];
    for (NSDictionary *myDict in vendorsArray)
    {
        NSString *catname=[myDict objectForKey:@"vendor_no"];
        
        [VendornumbersArray addObject:catname];
        
    }
    
    NSUInteger objIdx = [VendornumbersArray containsObject:ChangevendorNO];
    // //NSLog(@"%lu",(unsigned long)objIdx);
    if(objIdx == 0)
    {
        // //NSLog(@"condition true");
        
        NSString *updateSQL =@"UPDATE vendor SET vendor_no=?,vendor_terms=?,vendor_min_order=?,vendor_commission_percent=?,vendor_company_name=?,vendor_flat_rent_rate=?,vendor_tax_id=?,vendor_billable_department=?,vendor_social_security_no=?,vendor_po_delivery_method=?,vendor_street_address=?,vendor_extended_address=?,vendor_city=?,vendor_state=?,vendor_zip_code=?,vendor_country=?,vendor_first_name=?,vendor_last_name=?,vendor_telephone_number=?,vendor_fax_number=?,vendor_email=?,vendor_website=? WHERE vendor_no=?";
        
        
        NSMutableArray *insertVDataArray=[[NSMutableArray alloc]initWithObjects:ChangevendorNO,ChangeTerms,ChangeminimumOrder,Changecommission,ChangeCompanyname,ChangeFlatRent,ChangeTaxtID,ChangeBillable,ChangeSocialsecurity,POstr,ChangestreetAddress,ChangeExtendedAddress,ChangeCity,Changestate,ChangeZipcode,Changecountry,Changefirstname,Changelastname,ChangephNUmber,Changefaxnumber,Changeemail,Changewebsite,vendorNumber, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL withArguments:insertVDataArray];
        
        NSString *querySQL = [NSString stringWithFormat: @"SELECT vendor_no,vendor_terms,vendor_min_order,vendor_commission_percent,vendor_company_name,vendor_flat_rent_rate,vendor_tax_id,vendor_billable_department,vendor_social_security_no,vendor_po_delivery_method,vendor_street_address,vendor_extended_address,vendor_city,vendor_state,vendor_zip_code,vendor_country,vendor_first_name,vendor_last_name,vendor_telephone_number,vendor_fax_number,vendor_email,vendor_website FROM vendor"];
        NSMutableArray *vendorsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:vendorsArray];
        
        NSMutableArray *rdarray=vendorsArray;
        
        [vendorPaginationObject setCompleteresultset:rdarray];
        
        [vendorPaginationObject  paginationinitializer:rdarray :6];
        
        [vendorPaginationObject paginationsegment].tintColor=[UIColor whiteColor];
        [[vendorPaginationObject paginationsegment] setFrame:CGRectMake(5, AddvendorBtn.frame.size.height+10,vendorsView.frame.size.width-10, 40)];
        
        [[vendorPaginationObject paginationsegment] addTarget:self action:@selector(segmentchanged3:) forControlEvents:UIControlEventValueChanged];
        
        NSInteger selectedsegindex;
        selectedsegindex=0;
        [vendorPaginationObject paginationsegment].selectedSegmentIndex=selectedsegindex;
        [vendorPaginationObject activateResults:selectedsegindex];
        [vendorsView addSubview:[vendorPaginationObject  paginationsegment]];
        [self editVendorViewRemove];
        [EditVendorTable reloadData];
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"vendor Data Successfully saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        
        NSString *selectquerySQL = [NSString stringWithFormat:@"SELECT vendor_no,vendor_terms,vendor_min_order,vendor_commission_percent,vendor_company_name,vendor_flat_rent_rate,vendor_tax_id,vendor_billable_department,vendor_social_security_no,vendor_po_delivery_method,vendor_street_address,vendor_extended_address,vendor_city,vendor_state,vendor_zip_code,vendor_country,vendor_first_name,vendor_last_name,vendor_telephone_number,vendor_fax_number,vendor_email,vendor_website,unique_id,created_timestamp,modified_timestamp,server_local FROM vendor WHERE vendor_no='%@'",vendorNO];
        NSMutableArray *selectVendorsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:selectquerySQL resultsArray:selectVendorsArray];
        
        NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
        [CategoryDict setObject:selectVendorsArray forKey:@"fields"];
        NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
        
        
        NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"UPDATE",[generalDataObject  userID],@"saveinfo.php?",str,@"vendor",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
                // //NSLog(@"%@",str);
                NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=vendor&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                
                // //NSLog(@"%@",str);
                
                NSURL *url=[NSURL URLWithString:string];
                NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                // //NSLog(@"%@",url);
                
                [request setHTTPMethod:@"POST"];
                [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                
                
                VendorConnection = [NSURLConnection connectionWithRequest:request delegate:self];
                
                [VendorConnection start];
                url=nil,request=nil,string=nil;
            }
        }
        CategoryDict=nil,jsonData=nil,jsonDict=nil,str=nil;
    }
    else
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Vendor ID already exist change the Vendor id" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        alert=nil;
        
    }

    
    [self vendordataMethod];
    POstr=nil;
}
-(void)CancelVendorData
{
    
}
#pragma mark - Save department Data Methods
-(void)SaveDeptData
{
    if (!DepartmentNamesArray)
    DepartmentNamesArray=[[NSMutableArray alloc]init];
    
      NSString *querySQL7 = [NSString stringWithFormat: @"SELECT department_id FROM department_details"];
    NSMutableArray *deptsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:deptsArray];
    @autoreleasepool {
        for (NSDictionary *myDict in deptsArray)
        {
            NSString *deptname=[myDict objectForKey:@"department_id"];
            
            [DepartmentNamesArray addObject:deptname];
            deptname=nil;
            
        }
    }
   
    NSString *DeptidStr=IDfield.text;
    NSString *deptDesStr=deptDestextView.text;
    NSString *catforthisDept=[NSString stringWithFormat:@"%@",CatforthisDeptBtn.titleLabel.text];
     NSString *printername=[NSString stringWithFormat:@"%@",DeptprinterBtn.titleLabel.text];
    NSString *unique_id=[generalDataObject  genRandStringLength:20];
    NSUInteger objIdx = [DepartmentNamesArray containsObject:DeptidStr];
    
    NSString *Time=[NSString stringWithFormat:@"%@:%@",MinitBtn.titleLabel.text,SecsBtn.titleLabel.text];
    
    // //NSLog(@"%lu",(unsigned long)objIdx);
    if(objIdx == 0) {
        // //NSLog(@"condition true");
  
        NSString *insertSQL =@"insert into department_printer_commands (department_printer, department_print_time,department_id) VALUES (?,?,?)";
        NSMutableArray *printerdataArray=[[NSMutableArray alloc]initWithObjects:printername,Time,DeptidStr, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:printerdataArray];
        insertSQL=nil;
        
        NSString *DeptinsertSQL =@"insert into department_details(department_id,department_description,category_id,unique_id,created_timestamp,modified_timestamp,department_foodstampable,department_totaltax,check_value) values(?,?,?,?,?,?,?,?,?)";
        NSMutableArray *deptsinsertArray=[[NSMutableArray alloc]initWithObjects:DeptidStr,deptDesStr,catforthisDept,unique_id,[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime],Deptfoodstampable,DepTaxValueStr,@"true", nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:DeptinsertSQL withArguments:deptsinsertArray];
        
        NSString *querySQL7 = [NSString stringWithFormat:@"SELECT department_id,department_description,category_id,department_foodstampable,department_totaltax,check_value FROM department_details"];
        
        NSMutableArray *deptsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:deptsArray];
        
        NSMutableArray *rdarray=deptsArray;
        [jobpaginationObject setCompleteresultset:rdarray];
        
        [jobpaginationObject  paginationinitializer:rdarray :10];
        
        [jobpaginationObject paginationsegment].tintColor=[UIColor whiteColor];
        [[jobpaginationObject paginationsegment] setFrame:CGRectMake(10, addDeptbtn.frame.size.height+10,depertmentView.frame.size.width-20, 40)];
        
        [[jobpaginationObject paginationsegment] addTarget:self action:@selector(segmentchanged2:) forControlEvents:UIControlEventValueChanged];
        
        NSInteger selectedsegindex;
        selectedsegindex=0;
        [jobpaginationObject paginationsegment].selectedSegmentIndex=selectedsegindex;
        updateTableArray2=[jobpaginationObject activateResults:selectedsegindex];
        [EditDeptTable reloadData];
        updateTableArray2=nil;
        
       UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"Department Data Successfully saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
       [alert show];
        alert=nil;
        
    
         NSString *selectquerySQL7 = [NSString stringWithFormat:@"SELECT department_id,department_description,category_id,unique_id,created_timestamp,modified_timestamp,department_foodstampable,department_totaltax,check_value,server_local FROM department_details WHERE department_id='%@'",DeptidStr];
        NSMutableArray *selectDeptsArray=[[NSMutableArray alloc]init];
        
        [[DataBaseManager dataBaseManager]execute:selectquerySQL7 resultsArray:selectDeptsArray];
        NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
        [CategoryDict setObject:selectDeptsArray forKey:@"fields"];
        
        NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
        
        
        NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(![generalDataObject  connectedToInternet]){
            
       
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str,@"department_details",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
        
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
        //// //NSLog(@"%@",str);
        NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=department_details&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        //// //NSLog(@"%@",str);
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
       // // //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        
        
        
        VendorConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [VendorConnection start];
                 string=nil,request=nil,url=nil;
            }
        }
         CategoryDict=nil,jsonData=nil,jsonDict=nil,str=nil;
    }
    else
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Department ID already exist change the Department id" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        
    }
    
    DeptidStr=nil;
    deptDesStr=nil;
    catforthisDept=nil;
    printername=nil;
    unique_id=nil,Time=nil;
  
}
-(void)SaveChangeDeptData
{
    
    NSString *DeptidStr=ChangeIDfield.text;
    NSString *DeptDesStr=ChangedeptDestextView.text;
    NSString *catdeptid=[NSString stringWithFormat:@"%@",ChangeCatforthisDeptBtn.titleLabel.text];
    NSString *printer=[NSString stringWithFormat:@"%@",ChangeDeptprinterBtn.titleLabel.text];
    
    
    NSString *updateSQL6 =@"UPDATE department_details SET  department_description=?, category_id=?,department_foodstampable=?,department_totaltax=? WHERE department_id=?";
    
    NSMutableArray *updateDeptArray=[[NSMutableArray alloc]initWithObjects:DeptDesStr,catdeptid,Editfoodstampable,DepTaxValueStr,DeptidStr, nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL6 withArguments:updateDeptArray];
    
    NSString *querySQL = [NSString stringWithFormat:@"SELECT * FROM department_printer_commands WHERE department_id='%@'",DeptidStr];
    NSMutableArray *printersArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:printersArray];
    
    
    if ([printersArray count]>0){
        
        NSString *Time=[NSString stringWithFormat:@"%@:%@",ChangeMinitBtn.titleLabel.text,ChangeSecsBtn.titleLabel.text];
        NSString *insertSQL =@"UPDATE  department_printer_commands SET department_printer=?, department_print_time=?,department_id=? WHERE department_id=? ";
        
        NSMutableArray *inserArray=[[NSMutableArray alloc]initWithObjects:printer,Time,DeptidStr,DeptidStr, nil];
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:inserArray];
        
        insertSQL=nil,Time=nil;
    }else{
        
        NSString *Time=[NSString stringWithFormat:@"%@:%@",ChangeMinitBtn.titleLabel.text,ChangeSecsBtn.titleLabel.text];
        
        NSString *insertSQL =@"insert into department_printer_commands (department_printer, department_print_time,department_id) VALUES (?,?,?)";
        NSMutableArray *inserArray=[[NSMutableArray alloc]initWithObjects:printer,Time,DeptidStr, nil];
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:inserArray];
        insertSQL=nil;
        Time=nil;
        
        
    }
    
    
    NSString *querySQL7 = [NSString stringWithFormat:@"SELECT department_id,department_description,category_id,department_foodstampable,department_totaltax,check_value FROM department_details"];
    NSMutableArray *deptsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:deptsArray];
    
    NSMutableArray *rdarray=deptsArray;
    [jobpaginationObject setCompleteresultset:rdarray];
    
    [jobpaginationObject  paginationinitializer:rdarray :10];
    
    [jobpaginationObject paginationsegment].tintColor=[UIColor whiteColor];
    [[jobpaginationObject paginationsegment] setFrame:CGRectMake(10, addDeptbtn.frame.size.height+10,depertmentView.frame.size.width-20, 40)];
    
    [[jobpaginationObject paginationsegment] addTarget:self action:@selector(segmentchanged2:) forControlEvents:UIControlEventValueChanged];
    
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [jobpaginationObject paginationsegment].selectedSegmentIndex=selectedsegindex;
    updateTableArray2=[jobpaginationObject activateResults:selectedsegindex];
    [depertmentView addSubview:[jobpaginationObject  paginationsegment]];
    
    [self Editdepartmentviewremove];
    
    [EditDeptTable reloadData];
    updateTableArray2=nil;
    
    UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"Department Data Successfully saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
    [alert show];
    alert=nil;
    NSString *selectquerySQL7 = [NSString stringWithFormat:@"SELECT department_id,department_description,category_id,unique_id,created_timestamp,modified_timestamp,department_foodstampable,department_totaltax,check_value,server_local FROM department_details WHERE department_id='%@'",DeptidStr];
    NSMutableArray *selectDeptsArray=[[NSMutableArray alloc]init];
    
    [[DataBaseManager dataBaseManager]execute:selectquerySQL7 resultsArray:selectDeptsArray];
    NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
    [CategoryDict setObject:selectDeptsArray forKey:@"fields"];
    NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
    
    
    NSError *err;
    
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
    
    NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    if(![generalDataObject  connectedToInternet]){
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"UPDATE",[generalDataObject  userID],@"saveinfo.php?",str,@"department_details",[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }
    else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
            // //NSLog(@"%@",str);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=department_details&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            VendorConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [VendorConnection start];
            url=nil,request=nil,string=nil;
        }
        jsonDict=nil,jsonData=nil,CategoryDict=nil,str=nil;
    }
    [self DeptDataMethod];
    
    DeptidStr=nil;
    DeptDesStr=nil;
    catdeptid=nil;
    printer=nil;
    
    
}
-(void)SaveDuplicateDeptData
{
    if (!DepartmentNamesArray)
        DepartmentNamesArray=[[NSMutableArray alloc]init];
    
    NSString *querySQL7 = [NSString stringWithFormat: @"SELECT department_id FROM department_details"];
    NSMutableArray *deptsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:deptsArray];
    @autoreleasepool {
        for (NSDictionary *myDict in deptsArray)
        {
            NSString *deptname=[myDict objectForKey:@"department_id"];
            
            [DepartmentNamesArray addObject:deptname];
            deptname=nil;
            
        }
    }
    NSString *DeptidStr=DuplicateIDfield.text;
    NSString *deptDesStr=DuplicatedeptDestextView.text;
    NSString *catforthisDept=[NSString stringWithFormat:@"%@",DuplicateCatforthisDeptBtn.titleLabel.text];
    NSString *printer=[NSString stringWithFormat:@"%@",DuplicateDeptprinterBtn.titleLabel.text];
    NSString *unique_id=[generalDataObject  genRandStringLength:20];
    
    NSString *Time=[NSString stringWithFormat:@"%@:%@",ChangeMinitBtn.titleLabel.text,ChangeSecsBtn.titleLabel.text];
    
    NSUInteger objIdx = [DepartmentNamesArray containsObject:DeptidStr];
    // //NSLog(@"%lu",(unsigned long)objIdx);
    if(objIdx == 0) {
        // //NSLog(@"condition true");
        
        NSString *insertSQL =@"insert into department_printer_commands (department_printer, department_print_time,department_id) VALUES (?,?,?)";
        NSMutableArray *printerdataArray=[[NSMutableArray alloc]initWithObjects:printer,Time,DeptidStr, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:printerdataArray];
        insertSQL=nil;
        
        NSString *DeptinsertSQL =@"insert into department_details(department_id,department_description,category_id,unique_id,created_timestamp,modified_timestamp,department_foodstampable,department_totaltax,check_value) values(?,?,?,?,?,?,?,?,?)";
        NSMutableArray *deptsinsertArray=[[NSMutableArray alloc]initWithObjects:DeptidStr,deptDesStr,catforthisDept,unique_id,[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime],EditDeptfoodstampable,DepTaxValueStr,@"true", nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:DeptinsertSQL withArguments:deptsinsertArray];
        
        
        
        insertSQL=nil;
        
        NSString *querySQL7 = [NSString stringWithFormat:@"SELECT department_id,department_description,category_id,department_foodstampable,department_totaltax,check_value FROM department_details"];
        NSMutableArray *deptsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:deptsArray];
        
        NSMutableArray *rdarray=deptsArray;
        
        [jobpaginationObject setCompleteresultset:rdarray];
        
        [jobpaginationObject  paginationinitializer:rdarray :10];
        
        [jobpaginationObject paginationsegment].tintColor=[UIColor whiteColor];
        [[jobpaginationObject paginationsegment] setFrame:CGRectMake(10, addDeptbtn.frame.size.height+10,depertmentView.frame.size.width-20, 40)];
        
        [[jobpaginationObject paginationsegment] addTarget:self action:@selector(segmentchanged2:) forControlEvents:UIControlEventValueChanged];
        
        NSInteger selectedsegindex;
        selectedsegindex=0;
        [jobpaginationObject paginationsegment].selectedSegmentIndex=selectedsegindex;
        updateTableArray2=[jobpaginationObject activateResults:selectedsegindex];
        [depertmentView addSubview:[jobpaginationObject paginationsegment]];
        [self duplicatedepartmentViewremove];
        [EditDeptTable reloadData];
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"Department Data Successfully saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        
        updateTableArray2=nil,alert=nil;
        
        NSString *selectquerySQL7 = [NSString stringWithFormat:@"SELECT department_id,department_description,category_id,unique_id,created_timestamp,modified_timestamp,department_foodstampable,department_totaltax,check_value,server_local FROM department_details WHERE department_id='%@'",DeptidStr];
        NSMutableArray *selectDeptsArray=[[NSMutableArray alloc]init];
        
        [[DataBaseManager dataBaseManager]execute:selectquerySQL7 resultsArray:selectDeptsArray];
        NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
        [CategoryDict setObject:selectDeptsArray forKey:@"fields"];
        NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
        
        
        NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str,@"department_details",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
                // //NSLog(@"%@",str);
                NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=department_details&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                
                // //NSLog(@"%@",str);
                
                NSURL *url=[NSURL URLWithString:string];
                NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
                // //NSLog(@"%@",url);
                
                [request setHTTPMethod:@"POST"];
                [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
                //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
                
                
                
                VendorConnection = [NSURLConnection connectionWithRequest:request delegate:self];
                
                [VendorConnection start];
                url=nil,request=nil,string=nil;
            }
        }
        jsonDict=nil,jsonData=nil,CategoryDict=nil,str=nil;
    }
    else
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Department ID already exist change the Department id" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        alert=nil;
        
    }
    DeptidStr=nil;
    deptDesStr=nil;
    catforthisDept=nil;
    
    unique_id=nil,Time=nil;
    [self DeptDataMethod];
    
}
-(void)CancelDeptData
{
    deptDestextView.text=@"";
    IDfield.text=@"";
    
}

-(void)segmentchanged:(UISegmentedControl *)sender
{
    //// //NSLog(@"active results %@ ",[paginationObject activeresultset]);
    [paginationObject activateResults:[paginationObject  paginationsegment].selectedSegmentIndex];
      [self getcategoryDatamethod];
    [editCategoryTable reloadData];
}
-(void)segmentchanged2:(UISegmentedControl *)sender
{
    //// //NSLog(@"active results %@ ",[paginationObject activeresultset]);
    [jobpaginationObject activateResults:[jobpaginationObject paginationsegment].selectedSegmentIndex];
    [self DeptDataMethod];
    [EditDeptTable reloadData];
}
-(void)segmentchanged3:(UISegmentedControl *)sender
{
    //// //NSLog(@"active results %@ ",[paginationObject activeresultset]);
    [vendorPaginationObject activateResults:[vendorPaginationObject paginationsegment].selectedSegmentIndex];
     [self vendordataMethod];
    [EditVendorTable reloadData];
}
-(void)segmentchanged4:(UISegmentedControl *)sender
{
   
  //  // //NSLog(@"active results %@ ",[paginationObject activeresultset]);
   [productPaginationObject  activateResults:[productPaginationObject paginationsegment].selectedSegmentIndex];
    
   // // //NSLog(@"%@",[productPaginationObject  activeresultset]);
    
    //[editProductTable scrollToRowAtIndexPath:0 atScrollPosition: animated:NO];
    [self productRelatedDataMethod];
    [editProductTable reloadData];
    
}
#pragma mark - Save category Data Methods
-(void)SaveCategorydata
{
    if (!categorynamesArray)
    categorynamesArray=[[NSMutableArray alloc]init];
    
   NSString *querySQL6 = [NSString stringWithFormat: @"SELECT category_id FROM category_details"];
    NSMutableArray *catesArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL6 resultsArray:catesArray];
    @autoreleasepool {
        for (NSDictionary *myDict in catesArray)
        {
            
            NSString *catname=[myDict objectForKey:@"category_id"];
            
            [categorynamesArray addObject:catname];
            catname=nil;
            
        }
    }
    NSString *categoryidStr=categoryidField.text;
    NSString *catDesStr=catDesField.text;
    NSString *unique_id=[generalDataObject  genRandStringLength:20];
    NSUInteger objIdx = [categorynamesArray containsObject:categoryidStr];
    //// //NSLog(@"%lu",(unsigned long)objIdx);
    if(objIdx == 0) {
        // //NSLog(@"condition true");
    
        NSString *insertSQL =@"insert into category_details(category_id,category_description,unique_id,created_timestamp,modified_timestamp) values(?,?,?,?,?)";
        NSMutableArray *cateinsertsArray=[[NSMutableArray alloc]initWithObjects:categoryidStr,catDesStr,unique_id,[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:cateinsertsArray];
        
        
        NSString *querySQL6 = [NSString stringWithFormat:@"SELECT category_id,category_description FROM category_details"];
        NSMutableArray *categorysArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL6 resultsArray:categorysArray];
        
        NSMutableArray *rdarray=categorysArray;
        
        //// //NSLog(@"%@",rdarray);
        //updateTableArray=[[NSMutableArray alloc] init];
        
        [paginationObject setCompleteresultset:rdarray];
        
        [paginationObject  paginationinitializer:rdarray :5];
        
        [paginationObject paginationsegment].tintColor=[UIColor whiteColor];
        [[paginationObject paginationsegment] setFrame:CGRectMake(10, addcategoryBtn.frame.size.height+10,addCategoryBackView.frame.size.width-20, 40)];
        
        [[paginationObject paginationsegment] addTarget:self action:@selector(segmentchanged:) forControlEvents:UIControlEventValueChanged];
    
        NSInteger selectedsegindex;
        selectedsegindex=0;
        [paginationObject paginationsegment].selectedSegmentIndex=selectedsegindex;
        updateTableArray=[paginationObject activateResults:selectedsegindex];
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"Category Data Successfully saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        alert=nil,updateTableArray=nil;
    
         NSString *selectquerySQL6 = [NSString stringWithFormat:@"SELECT category_id,category_description,unique_id,created_timestamp,modified_timestamp,server_local FROM category_details WHERE category_id='%@'",categoryidStr];
        NSMutableArray *selectcategorysArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:selectquerySQL6 resultsArray:selectcategorysArray];
        
        NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
        [CategoryDict setObject:selectcategorysArray forKey:@"fields"];
        
        NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
        
        
        NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str,@"category_details",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
       
        
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
       // // //NSLog(@"%@",str);
        NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=category_details&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        //// //NSLog(@"%@",str);
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
        //// //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        
               
        
        CategoryConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [CategoryConnection start];
                string=nil,request=nil,url=nil;
                
            }
        }
         CategoryDict=nil,jsonData=nil,jsonDict=nil,str=nil;
    }
    else
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Category ID already exist change the category id" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        alert=nil;
        
    }
    categoryidStr=nil;
    catDesStr=nil;
    unique_id=nil;
}
-(void)SaveChangeCategorydata
{
    NSString *categoryidStr=ChangecategoryidField.text;
    NSString *catDesStr=ChengecatDesField.text;
    if (!categorynamesArray)
        categorynamesArray=[[NSMutableArray alloc]init];
    
    NSString *insertquerySQL6 = [NSString stringWithFormat: @"SELECT category_id FROM category_details"];
    NSMutableArray *catesArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:insertquerySQL6 resultsArray:catesArray];
    @autoreleasepool {
        for (NSDictionary *myDict in catesArray)
        {
            
            NSString *catname=[myDict objectForKey:@"category_id"];
            
            [categorynamesArray addObject:catname];
            catname=nil;
            
        }
    }
    
    NSString *updateSQL5 =@"UPDATE category_details SET category_description=? WHERE category_id=?";
    NSMutableArray *updteArray=[[NSMutableArray alloc]initWithObjects:catDesStr,categoryidStr, nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL5 withArguments:updteArray];
    
    NSString *querySQL6 = [NSString stringWithFormat: @"SELECT category_id,category_description FROM category_details"];
    NSMutableArray *categorysArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL6 resultsArray:categorysArray];
    
    NSMutableArray *rdarray=categorysArray;
    
    //// //NSLog(@"%@",rdarray);
    //updateTableArray=[[NSMutableArray alloc] init];
    
    [paginationObject setCompleteresultset:rdarray];
    
    [paginationObject  paginationinitializer:rdarray :5];
    
    [paginationObject paginationsegment].tintColor=[UIColor whiteColor];
    [[paginationObject paginationsegment] setFrame:CGRectMake(10, addcategoryBtn.frame.size.height+10,addCategoryBackView.frame.size.width-20, 40)];
    
    [[paginationObject paginationsegment] addTarget:self action:@selector(segmentchanged:) forControlEvents:UIControlEventValueChanged];
    
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [paginationObject paginationsegment].selectedSegmentIndex=selectedsegindex;
    updateTableArray=[paginationObject activateResults:selectedsegindex];
    [addCategoryBackView addSubview:[paginationObject  paginationsegment]];
    [self editcategoryViewremove];
    [editCategoryTable reloadData];
    UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"Category Data Successfully saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
    [alert show];
    
    
    NSString *selectquerySQL6 = [NSString stringWithFormat:@"SELECT category_id,category_description,unique_id,created_timestamp,modified_timestamp,server_local FROM category_details WHERE category_id='%@'",categoryidStr];
    NSMutableArray *selectcategorysArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:selectquerySQL6 resultsArray:selectcategorysArray];
    
    NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
    [CategoryDict setObject:selectcategorysArray forKey:@"fields"];
    NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
    
    
    NSError *err;
    
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
    
    NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    
    
    if(![generalDataObject  connectedToInternet])
    {
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"UPDATE",[generalDataObject  userID],@"saveinfo.php?",str,@"category_details",[generalDataObject getsystemDatetime], nil];
        
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
    }
    else if([generalDataObject  connectedToInternet])
    {
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
            // //NSLog(@"%@",str);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=category_details&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            CategoryConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [CategoryConnection start];
            request=nil;url=nil,string=nil;
        }
        CategoryDict=nil,jsonData=nil,jsonDict=nil,str=nil;
    }
    
    [self getcategoryDatamethod];
    categoryidStr=nil,catDesStr=nil;
}
-(void)CancelCatedorydataClicked
{
    [categoryidField setText:@""];
    [catDesField setText:@""];
}
#pragma mark - TableView Deletegate and datasource methods
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView==editProductTable ){
        if (indexPath.row==0)
        {
            
            return 50;
        }
        
        else
        {
            return 80;
        }
    }else if (tableView==editCategoryTable ){
        if (indexPath.row==0)
        {
            
            return 40;
        }
        
        else
        {
            return 80;
           
        }
    }else if (tableView==EditDeptTable ){
        if (indexPath.row==0)
        {
            
            return 50;
        }
        
        else
        {
            return 80;
        }
    }else if (tableView==SalesHistoryTable)
    {
        if (indexPath.row==0)
        {
            
            return 50;
        }
        
        else
        {
        return 80;
        }
    }
    else
    {
        return 50;
        
    }
    
    
    return YES;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    // This will create a "invisible" footer
    return 0.01f;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return [UIView new];
    
    // If you are not using ARC:
    // return [[UIView new] autorelease];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    if (tableView== editCategoryTable){
        return [[paginationObject activeresultset] count]+1;
        
    }else if (tableView== categorysListTable)
    {
        return [categorynamesArray count];
        
    }else if (tableView== ChangecategorysListTable){
        return [categorynamesArray count];
        
    }else if (tableView== DuplicatecategorysListTable){
        return [categorynamesArray count];
        
    }else if (tableView== DeliveryTypesTable){
        return [DeliverymethodsArray count];
        
    }else if (tableView== VendorsTable)
    {
        return [VendornumbersArray count];
        
    }else if (tableView== DepartmentsTable)
    {
        return [DepartmentNamesArray count];
        
    }else if (tableView== DuplicateVendorsTable)
    {
        return [VendornumbersArray count];
        
    }else if (tableView== DuplicateDepartmentsTable)
    {
        return [DepartmentNamesArray count];
        
    }else if (tableView== ChangeVendorsTable)
    {
        return [VendornumbersArray count];
        
    }else if (tableView== ChangeDepartmentsTable)
    {
        return [DepartmentNamesArray count];
        
    }else if (tableView== changeDeliveryTypesTable)
    {
        return [DeliverymethodsArray count];
        
    }else if (tableView== EditDeptTable)
    {
        return [[jobpaginationObject activeresultset] count]+1;
        
    }else if (tableView== EditVendorTable)
    {
        return [[vendorPaginationObject activeresultset] count]+1;
        
    }else if (tableView== editProductTable)
    {
        return [[productPaginationObject  activeresultset] count]+1;
        
    }else if (tableView== PrinterslistTable)
    {
        return [PrinterslistArray count];
        
    }else if (tableView== ChangePrinterslistTable)
    {
        return [PrinterslistArray count];
        
    }else if (tableView== DuplicatePrinterslistTable)
    {
        return [PrinterslistArray count];
        
    }else if (tableView== CommissionsTable)
    {
        return [OptCommissionsArray count];
        
    }else if (tableView== AlternateTable)
    {
        return [SkusArray count];
        
    }else if (tableView== ItemsListTable)
    {
        return [itemsListArray count];
        
    }if ([ModifierItemNosArray count]>0){
   if (tableView== modifierItemsTable){
        return [ModifierItemNosArray count]+1;
        
    }
    }else if (tableView== OpVendorslistTable)
    {
        return [OpVendorsArray count];
        
    }else if (tableView == OrderingInfoTable)
    {
        return [VendorPartsArray count]+1;
    }else if (tableView == DisplaySettable)
    {
        return [[productPaginationObject   ResultspersetArray] count];
        
        
    }else if (tableView == PCategorysTable)
    {
        return [categorynamesArray count];
        
    }else if (tableView==PdepartmentsTable)
    {
        return [DepartmentNamesArray count];
        
        
    }else if (tableView==SearchlistTable)
    {
        return [SearchDataArray count];
        
    }else if (tableView==MinitslistTable)
    {
        return [MinitsArray count];
    }else if (tableView==SecslistTable)
    {
        return [MinitsArray count];
        
    }else if (tableView==ChangeMinitslistTable)
    {
        return [MinitsArray count];
    }else if (tableView==ChangeSecslistTable)
    {
        return [MinitsArray count];
        
    }else  if (tableView==DuplicateMinitslistTable)
    {
        return [MinitsArray count];
    }else if (tableView==DuplicateSecslistTable)
    {
        return [MinitsArray count];
        
    }else if (tableView==SalesHistoryTable)
    {
        return [invoiceItemsArray count]+1;
        
    }
    return YES;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (tableView == editProductTable){
        
        ProductCell  *cell = (ProductCell *)[tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
        
        if(!cell) {
            [[NSBundle mainBundle] loadNibNamed:@"ProductCell" owner:self options:nil];
            cell = productCell;
        }
        
       // // //NSLog(@"Dict :-%@",dict);
        if (indexPath.row==0){
            cell.itemName_TextView.text = @"ItemNo";
            cell.itemNumber_TextView.text =@"ItemName";
            cell.price_TextView.text =@"Price";
            cell.stock_TextView.text =@"Stock";
            cell.description_TextView.text =@"Des2";
            cell.vendor_TextView.text =@"Vendor";
            
            cell.itemName_TextView.textColor=[UIColor blackColor];
            cell.itemNumber_TextView.textColor=[UIColor blackColor];
            cell.price_TextView.textColor=[UIColor blackColor];
            cell.stock_TextView.textColor=[UIColor blackColor];
            cell.description_TextView.textColor=[UIColor blackColor];
            cell.vendor_TextView.textColor=[UIColor blackColor];
            cell.contentView.backgroundColor=[UIColor colorWithRed:200.0f/255.0f green:200.0f/255.0f blue:200.0f/255.0f alpha:1.0f];
            cell.edit_Button.hidden=YES;
            cell.view_Button.hidden=YES;
            cell.duplicate_Button.hidden=YES;
            cell.delete_Button.hidden=YES;
            
        }else{
        
            NSDictionary *dict =[[productPaginationObject  activeresultset] objectAtIndex:indexPath.row-1];
            //// //NSLog(@"Dict _%@",dict);
            
            cell.itemName_TextView.text = [dict valueForKey:@"inventary_item_name"];
            cell.itemNumber_TextView.text =[dict valueForKey:@"inventory_item_no"];
            cell.price_TextView.text =[dict valueForKey:@"inventary_price_change"];
            cell.stock_TextView.text =[dict valueForKey:@"inventary_in_stock"];
            cell.description_TextView.text =[dict valueForKey:@"inventary_second_description"];
            cell.vendor_TextView.text =[VendorpartNosArray objectAtIndex:indexPath.row-1];
            
            cell.itemName_TextView.textColor=[UIColor whiteColor];
            cell.itemNumber_TextView.textColor=[UIColor whiteColor];
            cell.price_TextView.textColor=[UIColor whiteColor];
            cell.stock_TextView.textColor=[UIColor whiteColor];
            cell.description_TextView.textColor=[UIColor whiteColor];
            cell.vendor_TextView.textColor=[UIColor whiteColor];
            
            cell.edit_Button.hidden=NO;
            cell.view_Button.hidden=NO;
            cell.duplicate_Button.hidden=NO;
            cell.delete_Button.hidden=NO;
            
            cell.edit_Button.tag=indexPath.row;
            cell.view_Button.tag=indexPath.row;
            cell.duplicate_Button.tag=indexPath.row;
            cell.delete_Button.tag=indexPath.row;
            
            
           
            
            if (indexPath.row%2==0){
               
            cell.contentView.backgroundColor=[UIColor colorWithRed:64.0f/255.0f green:96.0f/255.0f blue:120.0f/255.0f alpha:1.0f];
            }else
            {
            cell.contentView.backgroundColor=[UIColor colorWithRed:56.0f/255.0f green:104.0f/255.0f blue:128.0f/255.0f alpha:1.0f];
                              
            }

        }
        
        
        return cell;
        
    }else if (tableView == editCategoryTable){
        
        CategoryCell  *cell = (CategoryCell *)[tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
        
        if(!cell) {
            [[NSBundle mainBundle] loadNibNamed:@"CategoryCell" owner:self options:nil];
            cell = categoryCell;
        }
        
      
          if (indexPath.row==0){
              cell.categoryname_TextView.text=@"CategoryID";
              cell.categoryDes_TextView.text=@"Description";
               cell.contentView.backgroundColor=[UIColor colorWithRed:200.0f/255.0f green:200.0f/255.0f blue:200.0f/255.0f alpha:1.0f];
              
              cell.categoryname_TextView.textColor=[UIColor blackColor];
              cell.categoryDes_TextView.textColor=[UIColor blackColor];
              cell.edit_Button.hidden=YES;
              cell.delete_Button.hidden=YES;
              
          }else{
              
              NSDictionary *dict =[[paginationObject activeresultset] objectAtIndex:indexPath.row-1];
              cell.categoryname_TextView.text=[dict valueForKey:@"category_id"];
              cell.categoryDes_TextView.text=[dict valueForKey:@"category_description"];
              
              cell.categoryname_TextView.textColor=[UIColor whiteColor];
              cell.categoryDes_TextView.textColor=[UIColor whiteColor];
              cell.edit_Button.hidden=NO;
              cell.delete_Button.hidden=NO;
              cell.edit_Button.tag=indexPath.row;
              cell.delete_Button.tag=indexPath.row;
              if (indexPath.row%2==0){
                  
                  cell.contentView.backgroundColor=[UIColor colorWithRed:64.0f/255.0f green:96.0f/255.0f blue:120.0f/255.0f alpha:1.0f];
              }else
              {
                  cell.contentView.backgroundColor=[UIColor colorWithRed:56.0f/255.0f green:104.0f/255.0f blue:128.0f/255.0f alpha:1.0f];
                  
              }
              
          }
        
      
        
        return cell;
        
    }else if (tableView == EditDeptTable){
        
        DepartmentCell  *cell = (DepartmentCell *)[tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
        
        if(!cell) {
            [[NSBundle mainBundle] loadNibNamed:@"DepartmentCell" owner:self options:nil];
            cell = departmentCell;
        }
        
        
        if (indexPath.row==0){
            cell.Departmentname_TextView.text=@"DepartmentID";
            cell.DepartmentDes_TextView.text=@"Description";
             cell.DepartmentCategory_TextView.text=@"CategoryID";
            cell.contentView.backgroundColor=[UIColor colorWithRed:200.0f/255.0f green:200.0f/255.0f blue:200.0f/255.0f alpha:1.0f];
            
            cell.Departmentname_TextView.textColor=[UIColor blackColor];
            cell.DepartmentDes_TextView.textColor=[UIColor blackColor];
            cell.DepartmentCategory_TextView.textColor=[UIColor blackColor];
            cell.edit_Button.hidden=YES;
            cell.duplicate_Button.hidden=YES;
            cell.delete_Button.hidden=YES;
         
            
        }else{
            
            NSDictionary *dict =[[jobpaginationObject activeresultset] objectAtIndex:indexPath.row-1];
            cell.Departmentname_TextView.text=[dict valueForKey:@"department_id"];
            cell.DepartmentDes_TextView.text=[dict valueForKey:@"department_description"];
             cell.DepartmentCategory_TextView.text=[dict valueForKey:@"category_id"];
            
            cell.Departmentname_TextView.textColor=[UIColor whiteColor];
            cell.DepartmentDes_TextView.textColor=[UIColor whiteColor];
             cell.DepartmentCategory_TextView.textColor=[UIColor whiteColor];
            cell.edit_Button.hidden=NO;
            cell.duplicate_Button.hidden=NO;
            cell.delete_Button.hidden=NO;
            cell.edit_Button.tag=indexPath.row;
            cell.duplicate_Button.tag=indexPath.row;
            cell.delete_Button.tag=indexPath.row;
            if (indexPath.row%2==0){
                
                cell.contentView.backgroundColor=[UIColor colorWithRed:64.0f/255.0f green:96.0f/255.0f blue:120.0f/255.0f alpha:1.0f];
            }else
            {
                cell.contentView.backgroundColor=[UIColor colorWithRed:56.0f/255.0f green:104.0f/255.0f blue:128.0f/255.0f alpha:1.0f];
                
            }
            
        }
        
        return cell;
        
    }
    else if (tableView == EditVendorTable){
        
        VendorCell  *cell = (VendorCell *)[tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
        
        if(!cell) {
            [[NSBundle mainBundle] loadNibNamed:@"VendorCell" owner:self options:nil];
            cell = vendorCell;
        }
        
        
        if (indexPath.row==0){
            cell.vendorNumber_TextView.text=@"VendorNo";
            cell.vendorName_TextView.text=@"CompanyName";
            cell.contentView.backgroundColor=[UIColor colorWithRed:200.0f/255.0f green:200.0f/255.0f blue:200.0f/255.0f alpha:1.0f];
            
            cell.vendorNumber_TextView.textColor=[UIColor blackColor];
            cell.vendorName_TextView.textColor=[UIColor blackColor];
            cell.edit_Button.hidden=YES;
            cell.delete_Button.hidden=YES;
            
        }else{
            
            NSDictionary *dict =[[vendorPaginationObject activeresultset] objectAtIndex:indexPath.row-1];
            cell.vendorNumber_TextView.text=[dict valueForKey:@"vendor_no"];
            cell.vendorName_TextView.text=[dict valueForKey:@"vendor_company_name"];
            
            cell.vendorNumber_TextView.textColor=[UIColor whiteColor];
            cell.vendorName_TextView.textColor=[UIColor whiteColor];
            cell.edit_Button.hidden=NO;
            cell.delete_Button.hidden=NO;
            cell.edit_Button.tag=indexPath.row;
            cell.delete_Button.tag=indexPath.row;
            if (indexPath.row%2==0){
                
                cell.contentView.backgroundColor=[UIColor colorWithRed:64.0f/255.0f green:96.0f/255.0f blue:120.0f/255.0f alpha:1.0f];
            }else
            {
                cell.contentView.backgroundColor=[UIColor colorWithRed:56.0f/255.0f green:104.0f/255.0f blue:128.0f/255.0f alpha:1.0f];
                
            }
            
        }
        
        
        
        return cell;
        
    }
    else if (tableView == SalesHistoryTable){
        
        InventorySalesCell  *cell = (InventorySalesCell *)[tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
        
        if(!cell) {
            [[NSBundle mainBundle] loadNibNamed:@"InventorySalesCell" owner:self options:nil];
            cell = inventorySalesCell;
        }
        
        
        if (indexPath.row==0){
            cell.sno_TextView.text=@"S.No";
            cell.itemNo_TextView.text=@"CompanyName";
            cell.discount_TextView.text=@"Discount";
            cell.tax_TextView.text=@"tax";
            cell.cost_TextView.text=@"Cost";
            cell.avgCost_TextView.text=@"AvgCost";
            cell.qty_TextView.text=@"Qty";
            cell.date_TextView.text=@"Date";
            cell.contentView.backgroundColor=[UIColor colorWithRed:200.0f/255.0f green:200.0f/255.0f blue:200.0f/255.0f alpha:1.0f];
            
            cell.sno_TextView.textColor=[UIColor blackColor];
            cell.itemNo_TextView.textColor=[UIColor blackColor];
            cell.discount_TextView.textColor=[UIColor blackColor];
            cell.tax_TextView.textColor=[UIColor blackColor];
            cell.cost_TextView.textColor=[UIColor blackColor];
            cell.avgCost_TextView.textColor=[UIColor blackColor];
            cell.qty_TextView.textColor=[UIColor blackColor];
            cell.date_TextView.textColor=[UIColor blackColor];
           
            
        }else{
           

            NSDictionary *myDict =[invoiceItemsArray objectAtIndex:indexPath.row-1];
            cell.sno_TextView.text=[SnosArray objectAtIndex:indexPath.row-1];
            cell.itemNo_TextView.text=[myDict objectForKey:@"item_id"];
            cell.discount_TextView.text=[myDict objectForKey:@"discount"];
            cell.tax_TextView.text=[myDict objectForKey:@"total_tax"];
            cell.cost_TextView.text=[myDict objectForKey:@"price_you_charge"];
            cell.avgCost_TextView.text=[myDict objectForKey:@"avg_cost"];
            cell.qty_TextView.text=[myDict objectForKey:@"item_quantity"];
            cell.date_TextView.text=[myDict objectForKey:@"created_timestamp"];
            
            cell.sno_TextView.textColor=[UIColor whiteColor];
            cell.itemNo_TextView.textColor=[UIColor whiteColor];
            cell.discount_TextView.textColor=[UIColor whiteColor];
            cell.tax_TextView.textColor=[UIColor whiteColor];
            cell.cost_TextView.textColor=[UIColor whiteColor];
            cell.avgCost_TextView.textColor=[UIColor whiteColor];
            cell.qty_TextView.textColor=[UIColor whiteColor];
            cell.date_TextView.textColor=[UIColor whiteColor];
           
            if (indexPath.row%2==0){
                
                cell.contentView.backgroundColor=[UIColor colorWithRed:64.0f/255.0f green:96.0f/255.0f blue:120.0f/255.0f alpha:1.0f];
            }else
            {
                cell.contentView.backgroundColor=[UIColor colorWithRed:56.0f/255.0f green:104.0f/255.0f blue:128.0f/255.0f alpha:1.0f];
                
            }
            
        }
        
        
        
        return cell;
        
    }
    else if (tableView == OrderingInfoTable){
        
        OrderingInfoCell  *cell = (OrderingInfoCell *)[tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
        
        if(!cell) {
            [[NSBundle mainBundle] loadNibNamed:@"OrderingInfoCell" owner:self options:nil];
            cell = orderingInfoCell;
        }
        
        
        if (indexPath.row==0){
            cell.vendorNo_TextView.text=@"VendorNo";
            cell.costPer_TextView.text=@"CostPer";
            cell.caseCost_TextView.text=@"CaseCost";
            cell.preffred_TextView.text=@"Preffred";
            cell.part_TextView.text=@"part#";
            cell.percase_TextView.text=@"#PerCase";
                      cell.contentView.backgroundColor=[UIColor colorWithRed:200.0f/255.0f green:200.0f/255.0f blue:200.0f/255.0f alpha:1.0f];
            
            cell.vendorNo_TextView.textColor=[UIColor blackColor];
            cell.costPer_TextView.textColor=[UIColor blackColor];
            cell.caseCost_TextView.textColor=[UIColor blackColor];
            cell.preffred_TextView.textColor=[UIColor blackColor];
            cell.part_TextView.textColor=[UIColor blackColor];
            cell.percase_TextView.textColor=[UIColor blackColor];
           
            cell.edit_Button.hidden=YES;
            cell.delete_Button.hidden=YES;
            cell.edit_Button.tag=indexPath.row;
            cell.delete_Button.tag=indexPath.row;
            
        }else{
            
            
           
            cell.vendorNo_TextView.text=[SelectedOpVendorsArray objectAtIndex:indexPath.row-1];
            cell.costPer_TextView.text=[CostpersArray objectAtIndex:indexPath.row-1];
            cell.caseCost_TextView.text=[CasecostsArray objectAtIndex:indexPath.row-1];
            cell.preffred_TextView.text=[preferredsArray objectAtIndex:indexPath.row-1];
            cell.part_TextView.text=[VendorPartsArray objectAtIndex:indexPath.row-1];
            cell.percase_TextView.text=[NumberincasesArray objectAtIndex:indexPath.row-1];
           
            
            cell.vendorNo_TextView.textColor=[UIColor whiteColor];
            cell.costPer_TextView.textColor=[UIColor whiteColor];
            cell.caseCost_TextView.textColor=[UIColor whiteColor];
            cell.preffred_TextView.textColor=[UIColor whiteColor];
            cell.part_TextView.textColor=[UIColor whiteColor];
            cell.percase_TextView.textColor=[UIColor whiteColor];
            cell.edit_Button.hidden=NO;
            cell.delete_Button.hidden=NO;
            cell.edit_Button.tag=indexPath.row;
            cell.delete_Button.tag=indexPath.row;
    
            if (indexPath.row%2==0){
                
                cell.contentView.backgroundColor=[UIColor colorWithRed:64.0f/255.0f green:96.0f/255.0f blue:120.0f/255.0f alpha:1.0f];
            }else
            {
                cell.contentView.backgroundColor=[UIColor colorWithRed:56.0f/255.0f green:104.0f/255.0f blue:128.0f/255.0f alpha:1.0f];
                
            }
            
        }
        
        
        
        return cell;
        
    }else if (tableView == modifierItemsTable){
        
        ModifierItemCell  *cell = (ModifierItemCell *)[tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
        
        if(!cell) {
            [[NSBundle mainBundle] loadNibNamed:@"ModifierItemCell" owner:self options:nil];
            cell = modifierItemCell;
        }
        
        
        if (indexPath.row==0){
            cell.itemNumber_Label.text=@"ItemNumber";
            cell.Description_Label.text=@"Description";
            cell.contentView.backgroundColor=[UIColor colorWithRed:200.0f/255.0f green:200.0f/255.0f blue:200.0f/255.0f alpha:1.0f];
            
            cell.itemNumber_Label.textColor=[UIColor blackColor];
            cell.Description_Label.textColor=[UIColor blackColor];
           
            cell.delete_Button.hidden=YES;
            
        }else{
            
           
            cell.itemNumber_Label.text=[ModifierItemNosArray objectAtIndex:indexPath.row-1];
            cell.Description_Label.text=[modifierNamesArray objectAtIndex:indexPath.row-1];
            
            cell.itemNumber_Label.textColor=[UIColor whiteColor];
            cell.Description_Label.textColor=[UIColor whiteColor];
            
            cell.delete_Button.hidden=NO;
            
            cell.delete_Button.tag=indexPath.row;
            if (indexPath.row%2==0){
                
                cell.contentView.backgroundColor=[UIColor colorWithRed:64.0f/255.0f green:96.0f/255.0f blue:120.0f/255.0f alpha:1.0f];
            }else
            {
                cell.contentView.backgroundColor=[UIColor colorWithRed:56.0f/255.0f green:104.0f/255.0f blue:128.0f/255.0f alpha:1.0f];
                
            }
            
        }
        
        return cell;
        
    }else{
        
        static NSString *CellIdentifier = @"Cell";
        
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        
        if(!cell) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];
        }
        
           if (tableView==MinitslistTable){
            cell.textLabel.text=[MinitsArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
                 cell.textLabel.textColor=[UIColor blackColor];
            }else if (tableView==SecslistTable)
            {
                cell.textLabel.text=[MinitsArray objectAtIndex:indexPath.row];
                cell.textLabel.textAlignment=NSTextAlignmentCenter;
                  cell.textLabel.textColor=[UIColor blackColor];
            }else if (tableView==ChangeMinitslistTable){
                cell.textLabel.text=[MinitsArray objectAtIndex:indexPath.row];
                cell.textLabel.textAlignment=NSTextAlignmentCenter;
                  cell.textLabel.textColor=[UIColor blackColor];
            }else if (tableView==ChangeSecslistTable)
            {
                cell.textLabel.text=[MinitsArray objectAtIndex:indexPath.row];
                cell.textLabel.textAlignment=NSTextAlignmentCenter;
                  cell.textLabel.textColor=[UIColor blackColor];
            }else if (tableView==DuplicateMinitslistTable)
            {
                cell.textLabel.text=[MinitsArray objectAtIndex:indexPath.row];
                cell.textLabel.textAlignment=NSTextAlignmentCenter;
                  cell.textLabel.textColor=[UIColor blackColor];
            }else if (tableView==DuplicateSecslistTable)
            {
                cell.textLabel.text=[MinitsArray objectAtIndex:indexPath.row];
                cell.textLabel.textAlignment=NSTextAlignmentCenter;
                  cell.textLabel.textColor=[UIColor blackColor];
            }else if (tableView== SearchlistTable)
            {
                cell.textLabel.text=[SearchDataArray objectAtIndex:indexPath.row];
                cell.textLabel.textAlignment=NSTextAlignmentCenter;
                  cell.textLabel.textColor=[UIColor blackColor];
                
            }
            if (tableView== OpVendorslistTable)
            {
                cell.textLabel.text=[OpVendorsArray objectAtIndex:indexPath.row];
                cell.textLabel.textAlignment=NSTextAlignmentCenter;
                  cell.textLabel.textColor=[UIColor blackColor];
                
            }else if (tableView== DisplaySettable)
            {
                cell.textLabel.text=[[productPaginationObject   ResultspersetArray] objectAtIndex:indexPath.row];
                cell.textLabel.textAlignment=NSTextAlignmentCenter;
                  cell.textLabel.textColor=[UIColor blackColor];
                
            }else if (tableView == PCategorysTable)
            {
                cell.textLabel.text=[categorynamesArray objectAtIndex:indexPath.row];
                cell.textLabel.textAlignment=NSTextAlignmentCenter;
            }else if (tableView == PdepartmentsTable)
            {
                cell.textLabel.text=[DepartmentNamesArray objectAtIndex:indexPath.row];
                cell.textLabel.textAlignment=NSTextAlignmentCenter;
                  cell.textLabel.textColor=[UIColor blackColor];
                
            }else if (tableView== ItemsListTable){
            
            cell.textLabel.text=[itemsListArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
                  cell.textLabel.textColor=[UIColor blackColor];
                
        }else if (tableView== DepartmentsTable)
        {
            cell.textLabel.text=[DepartmentNamesArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
              cell.textLabel.textColor=[UIColor blackColor];
        }else if (tableView== CommissionsTable)
        {
            cell.textLabel.text=[OptCommissionsArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
              cell.textLabel.textColor=[UIColor blackColor];
        }else if (tableView== VendorsTable)
        {
            cell.textLabel.text=[VendornumbersArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
        }else if (tableView== DuplicateDepartmentsTable)
        {
            cell.textLabel.text=[DepartmentNamesArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
              cell.textLabel.textColor=[UIColor blackColor];
        }else if (tableView== DuplicateVendorsTable)
        {
            cell.textLabel.text=[VendornumbersArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
              cell.textLabel.textColor=[UIColor blackColor];
        }else if (tableView== ChangeVendorsTable)
        {
            cell.textLabel.text=[VendornumbersArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
              cell.textLabel.textColor=[UIColor blackColor];
        }else if (tableView== ChangeDepartmentsTable)
        {
            cell.textLabel.text=[DepartmentNamesArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
              cell.textLabel.textColor=[UIColor blackColor];
            
        }else if (tableView== PrinterslistTable)
        {
            cell.textLabel.text=[PrinterslistArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
              cell.textLabel.textColor=[UIColor blackColor];
            
        }else if (tableView== ChangePrinterslistTable)
        {
            cell.textLabel.text=[PrinterslistArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
              cell.textLabel.textColor=[UIColor blackColor];
        }else if (tableView== DuplicatePrinterslistTable)
        {
            cell.textLabel.text=[PrinterslistArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
              cell.textLabel.textColor=[UIColor blackColor];
        }else if (tableView== DeliveryTypesTable)
        {
            
            cell.textLabel.text=[DeliverymethodsArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
              cell.textLabel.textColor=[UIColor blackColor];
        }else if (tableView== changeDeliveryTypesTable)
        {
            
            cell.textLabel.text=[DeliverymethodsArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
              cell.textLabel.textColor=[UIColor blackColor];
        }else if (tableView== categorysListTable)
        {
            
            cell.textLabel.text=[categorynamesArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
              cell.textLabel.textColor=[UIColor blackColor];
        }else if (tableView== DuplicatecategorysListTable)
        {
            cell.textLabel.text=[categorynamesArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
              cell.textLabel.textColor=[UIColor blackColor];
        }else if (tableView== ChangecategorysListTable)
        {
            
            cell.textLabel.text=[categorynamesArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
              cell.textLabel.textColor=[UIColor blackColor];
        }else if (tableView== AlternateTable){
            
            cell.textLabel.text=[SkusArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
            cell.textLabel.textColor=[UIColor blackColor];
            DeleteSkuBtn=[[UIButton alloc]init];
            [DeleteSkuBtn setFrame:CGRectMake(200, 10, 25, 25)];
            //[editBtn setTitle:@"edit" forState:UIControlStateNormal];
            [DeleteSkuBtn setImage:[UIImage imageNamed:@"removered.png"] forState:UIControlStateNormal];
            //[DeleteSkuBtn setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"removered" ofType:@"png"]] forState:UIControlStateNormal];
            
            [DeleteSkuBtn addTarget:self action:@selector(deleteSku:) forControlEvents:UIControlEventTouchUpInside];
            DeleteSkuBtn.tag=indexPath.row;
            [cell.contentView addSubview:DeleteSkuBtn];
            
        }
        return cell;
    }

}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   
    if (tableView==ItemsListTable){
        
        ItemsListTable.hidden=YES;

        NSString *selectedstr=[itemsListArray objectAtIndex:indexPath.row];
        NSString *selectedname=[NamesArray objectAtIndex:indexPath.row];
        [ModifieritemsDropdownBtn setTitle:selectedstr forState:UIControlStateNormal];
    
        if ([ModifierItemNosArray count]>0)
        {
            NSUInteger objIdx = [ModifierItemNosArray containsObject:selectedstr];
          
            
            // //NSLog(@"%lu",(unsigned long)objIdx);
            if(objIdx == 0 ){

                    [modifierNamesArray addObject:selectedname];
                    [ModifierItemNosArray addObject:selectedstr];
                    [modifierItemsTable reloadData];
                
              
            }else{
                
                
                UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Modifier Item  already exist" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
                [alert show];
                alert=nil;
            }
        }else{
            [modifierNamesArray addObject:selectedname];
            [ModifierItemNosArray addObject:selectedstr];
            [modifierItemsTable reloadData];
        }
        selectedstr=nil,selectedname=nil;
        
    }else if (tableView== OpVendorslistTable){
        OpVendorslistTable.hidden=YES;

        NSString *selectedstr=[OpVendorsArray objectAtIndex:indexPath.row];
       
        [AddOpVendorBtn setTitle:selectedstr forState:UIControlStateNormal];
       
       if ([SelectedOpVendorsArray count]>0)
        {
            NSUInteger objIdx = [SelectedOpVendorsArray containsObject:selectedstr];
         
            if(objIdx == 0 )
            {
                [SelectedOpVendorsArray addObject:selectedstr];
                [self AddvendorDetailsView];
                
                
            }else{
                
                UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Vendor   already  exist" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
                [alert show];
                alert=nil;
            }
        }else{
            
            [SelectedOpVendorsArray addObject:selectedstr];
            [self AddvendorDetailsView];
            //[OrderingInfoTable reloadData];
            
        }
        selectedstr=nil;
        
    }else if (tableView==PrinterslistTable){
        
        PrinterslistTable.hidden=YES;
        
        deptDestextView.hidden=NO;
        NSString *selectedstr=[PrinterslistArray objectAtIndex:indexPath.row];
        [DeptprinterBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
        
    }else if (tableView==DuplicatePrinterslistTable){
        
        DuplicatePrinterslistTable.hidden=YES;
        
        DuplicatedeptDestextView.hidden=NO;
        NSString *selectedstr=[PrinterslistArray objectAtIndex:indexPath.row];
        [DuplicateDeptprinterBtn setTitle:selectedstr forState:UIControlStateNormal];
        
    }else if (tableView==ChangePrinterslistTable){
        
        ChangePrinterslistTable.hidden=YES;
        
        ChangedeptDestextView.hidden=NO;
        NSString *selectedstr=[PrinterslistArray objectAtIndex:indexPath.row];
        [ChangeDeptprinterBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
        
    }else if (tableView==categorysListTable){
        
        categorysListTable.hidden=YES;
        
         IDfield.hidden=NO;
        NSString *selectedstr=[categorynamesArray objectAtIndex:indexPath.row];
        [CatforthisDeptBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
        
    }else if (tableView==DuplicatecategorysListTable){
        
        DuplicatecategorysListTable.hidden=YES;
        
        DuplicateIDfield.hidden=NO;
        NSString *selectedstr=[categorynamesArray objectAtIndex:indexPath.row];
        [DuplicateCatforthisDeptBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
        
    }else if (tableView==ChangecategorysListTable){
        
        ChangecategorysListTable.hidden=YES;
        
        ChangeIDfield.hidden=NO;
        NSString *selectedstr=[categorynamesArray objectAtIndex:indexPath.row];
        [ChangeCatforthisDeptBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
        
    }else if (tableView==DeliveryTypesTable){
        
        DeliveryTypesTable.hidden=YES;
        NSString *selectedstr=[DeliverymethodsArray objectAtIndex:indexPath.row];
        [DeliverymethodBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
        
    }else if (tableView==changeDeliveryTypesTable){
        
        changeDeliveryTypesTable.hidden=YES;
        NSString *selectedstr=[DeliverymethodsArray objectAtIndex:indexPath.row];
        [changeDeliverymethodBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
        
    }else if (tableView== VendorsTable){
        InStockField.hidden=NO;
        PriceWithTaxBtn.hidden=NO;
        VendorsTable.hidden=YES;
        
        NSString *selectedstr=[VendornumbersArray objectAtIndex:indexPath.row];
        [AddpricingBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
    }else if (tableView== DepartmentsTable){
        ItemNameField.hidden=NO;
        ItemNumberField.hidden=NO;
        DepartmentsTable.hidden=YES;
        NSString *selectedstr=[DepartmentNamesArray objectAtIndex:indexPath.row];
        UITableViewCell *selectedCell = [tableView  cellForRowAtIndexPath:indexPath];
        
        NSUInteger indexNO = [DepartmentNamesArray indexOfObject:selectedCell.textLabel.text];
        
        Tax=[depttaxesArray objectAtIndex:indexNO];
        
        foodstampable=[deptfoodsArray objectAtIndex:indexNO];
        [DepartmentBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
         [self settaxSelectionMethod];
    }else if (tableView== DuplicateVendorsTable){
        DuplicateInStockField.hidden=NO;
        DuplicatePriceWithTaxBtn.hidden=NO;
        DuplicateVendorsTable.hidden=YES;
        
        NSString *selectedstr=[VendornumbersArray objectAtIndex:indexPath.row];
        [DuplicateAddpricingBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
    }else if (tableView== DuplicateDepartmentsTable){
        DuplicateItemNameField.hidden=NO;
        DuplicateItemNumberField.hidden=NO;
        DuplicateDepartmentsTable.hidden=YES;
        
        
        NSString *selectedstr=[DepartmentNamesArray objectAtIndex:indexPath.row];
         UITableViewCell *selectedCell = [tableView  cellForRowAtIndexPath:indexPath];
        NSUInteger indexNO = [DepartmentNamesArray indexOfObject:selectedCell.textLabel.text];
        
        Tax=[depttaxesArray objectAtIndex:indexNO];
        
        Editfoodstampable=[deptfoodsArray objectAtIndex:indexNO];
        [self settaxSelectionMethod];
        
         selectedstr=nil;
        [DuplicateDepartmentBtn setTitle:selectedstr forState:UIControlStateNormal];
    }else if (tableView== ChangeVendorsTable){
    ChangeInStockField.hidden=NO;
        ChangePriceWithTaxBtn.hidden=NO;
       ChangeVendorsTable.hidden=YES;
        
        NSString *selectedstr=[VendornumbersArray objectAtIndex:indexPath.row];
        [ChangeAddpricingBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
    }else if (tableView== ChangeDepartmentsTable){
        ChangeItemNameField.hidden=NO;
        ChangeItemNumberField.hidden=NO;
        ChangeDepartmentsTable.hidden=YES;
        
        
        NSString *selectedstr=[DepartmentNamesArray objectAtIndex:indexPath.row];
        UITableViewCell *selectedCell = [tableView  cellForRowAtIndexPath:indexPath];
        NSUInteger indexNO = [DepartmentNamesArray indexOfObject:selectedCell.textLabel.text];
        
        Tax=[depttaxesArray objectAtIndex:indexNO];
        
        Editfoodstampable=[deptfoodsArray objectAtIndex:indexNO];
        [self settaxSelectionMethod];
        
        [ChangeDepartmentBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
    }else if (tableView== CommissionsTable){
        CommissionsTable.hidden=YES;
    
        NSString *selectedstr=[OptCommissionsArray objectAtIndex:indexPath.row];
        [optCommissionBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
    }else if (tableView== DisplaySettable){
        
        DisplaySettable.hidden=YES;
        //// //NSLog(@"%@",[productPaginationObject  ResultspersetArray]);
        SelectedResultsForSet=[[productPaginationObject   ResultspersetArray] objectAtIndex:indexPath.row];
        [ResultspersetBtn setTitle:SelectedResultsForSet forState:UIControlStateNormal];
       
        [self ProductpaginationMetod];
     
    }else if (tableView==PCategorysTable){
        [Pcategorypopup removeFromSuperview];
        
        NSString *selectedstr=[categorynamesArray objectAtIndex:indexPath.row];
        [CatField setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;

    }else if (tableView==PdepartmentsTable){
        [Pdeaprtmentpopup removeFromSuperview];
        
        NSString *selectedstr=[DepartmentNamesArray objectAtIndex:indexPath.row];
        [DeptField setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
    }else  if (tableView==SearchlistTable){
        
        SearchlistTable.hidden=YES;
        
        NSString *selectedstr=[SearchDataArray objectAtIndex:indexPath.row];
        SearchField.text=selectedstr;
        
         selectedstr=nil;
    }else if (tableView==MinitslistTable){
         MinitslistTable.hidden=YES;
        canceldeptbtn.hidden=NO;
        NSString *selectedstr=[MinitsArray objectAtIndex:indexPath.row];
        [MinitBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
    }else if (tableView==SecslistTable){
         SecslistTable.hidden=YES;
        
        NSString *selectedstr=[MinitsArray objectAtIndex:indexPath.row];
        [SecsBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
    }else if (tableView==ChangeMinitslistTable)
    {
        ChangeMinitslistTable.hidden=YES;
        Changecanceldeptbtn.hidden=NO;
        NSString *selectedstr=[MinitsArray objectAtIndex:indexPath.row];
        [ChangeMinitBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
    }else if (tableView==ChangeSecslistTable){
        ChangeSecslistTable.hidden=YES;
        
        NSString *selectedstr=[MinitsArray objectAtIndex:indexPath.row];
        [ChangeSecsBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
    }else if (tableView==DuplicateMinitslistTable){
        DuplicateMinitslistTable.hidden=YES;
        Duplicatecanceldeptbtn.hidden=NO;
        NSString *selectedstr=[MinitsArray objectAtIndex:indexPath.row];
        [DuplicateMinitBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
    }else  if (tableView==DuplicateSecslistTable){
        DuplicateSecslistTable.hidden=YES;
        
        NSString *selectedstr=[MinitsArray objectAtIndex:indexPath.row];
        [DuplicateSecsBtn setTitle:selectedstr forState:UIControlStateNormal];
         selectedstr=nil;
    }
}
-(void)EditOrderingInfoData:(UIButton *)sender
{
    selectedOrder=sender.tag;
    VendorpartStr=[VendorPartsArray objectAtIndex:selectedOrder];
    CostperStr=[CostpersArray objectAtIndex:selectedOrder];
    CaseCostStr=[CasecostsArray objectAtIndex:selectedOrder];
    Numberincasestr=[NumberincasesArray objectAtIndex:selectedOrder];
    PreferredStr=[preferredsArray objectAtIndex:selectedOrder];
    selectedorderinfo=YES;
    [self AddvendorDetailsView];
    
}

-(void)deleteSku:(UIButton *)sender
{
    NSInteger selected=sender.tag;
    [SkusArray removeObjectAtIndex:selected];
    [AlternateTable reloadData];
    
}


-(void)CancelInstantProductData
{
   [self viewProductViewremove];
}

-(void)ChangepricewithTaxClicked
{
    [self ChangeTotaltaxmethod];
}



-(void)SaveDuplicateProductNotes
{
    DuplicateproductNotes=NotesTextView.text;
    [self notesViewRemove];
}

-(void)DuplicateItemBtnClicked:(UIButton *)sender
{
    NSInteger selecteditem=sender.tag;
    
    if (selecteditem==100)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
            EditmodifierItem=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
            EditmodifierItem=@"yes";
        }
    }
    if (selecteditem==101)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
            EditCountthisItem=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
            EditCountthisItem=@"yes";
        }
    }
    if (selecteditem==102)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
            Editallowbuyback=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
            Editallowbuyback=@"yes";
        }
    }
    if (selecteditem==103)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
            Editprintonreceipt=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
            Editprintonreceipt=@"yes";
        }
    }
    if (selecteditem==104)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
            Editfoodstampable=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
            Editfoodstampable=@"yes";
        }
    }
    if (selecteditem==105)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
            Editpromptprice=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
            Editpromptprice=@"yes";
        }
    }
    
}

-(void)CancelDuplicateProductData
{
     [self duplicateProductViewremove];
}
-(void)DuplicatepricewithTaxClicked
{
    [self DuplicateTotaltaxmethod];
}
-(void)DuplicateAddpricingClicked
{
    if (DuplicateVendorsTable.hidden==1)
    {
        DuplicateInStockField.hidden=YES;
        DuplicatePriceWithTaxBtn.hidden=YES;
        DuplicateVendorsTable.hidden=NO;
        
    }
    else if (DuplicateVendorsTable.hidden==0)
    {
        DuplicateInStockField.hidden=NO;
        DuplicatePriceWithTaxBtn.hidden=NO;
        [DuplicateVendorsTable setHidden:YES];
        
    }
}
-(void)DuplicateTax1Clicked
{
    if (Duplicatetax1Btn.selected)
    {
        [Duplicatetax1Btn setSelected:NO];
        
    }
    else if(!Duplicatetax1Btn.selected)
    {
        [Duplicatetax1Btn setSelected:YES];
        
    }
    [self DuplicateTotaltaxmethod];
}
-(void)DuplicateTax2Clikced
{
    if (Duplicatetax2Btn.selected)
    {
        [Duplicatetax2Btn setSelected:NO];
        
    }
    else if(!Duplicatetax2Btn.selected)
    {
        [Duplicatetax2Btn setSelected:YES];
        
    }
    [self DuplicateTotaltaxmethod];
}
-(void)DuplicateTax3Clicked
{
    if (Duplicatetax3Btn.selected)
    {
        [Duplicatetax3Btn setSelected:NO];
        
    }
    else if(!Duplicatetax3Btn.selected)
    {
        [Duplicatetax3Btn setSelected:YES];
        
    }
    [self DuplicateTotaltaxmethod];
}
-(void)DuplicateBarBtnClicked
{
    if (DuplicateBarTaxBtn.selected)
    {
        [DuplicateBarTaxBtn setSelected:NO];
        
    }
    else if(!DuplicateBarTaxBtn.selected)
    {
        [DuplicateBarTaxBtn setSelected:YES];
        
    }
    [self DuplicateTotaltaxmethod];
}
-(void)DuplicateTotaltaxmethod
{
    costStr=DuplicatePriceyouChargeField.text;
    
    
    
    
    if (DuplicateBarTaxBtn.selected || !Duplicatetax1Btn.selected )
    {
        taxvalue=[costStr doubleValue];
        TaxValueStr=@"Bartax";
        ProductTotalTax=0;
    }
    if (Duplicatetax1Btn.selected)
    {
        double pcntYes=(([tax1Rate doubleValue]*[costStr doubleValue])/100);
        // //NSLog(@"%f",pcntYes);
        taxvalue=[costStr doubleValue]+pcntYes;
        TaxValueStr=tax1Name;
       
        ProductTotalTax=[tax1Rate floatValue];
        
    }
    if (Duplicatetax2Btn.selected)
    {
        double pcntYes=(([tax2Rate doubleValue]*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        TaxValueStr=tax2Name;
        
        ProductTotalTax=[tax2Rate floatValue];
        
    }
    if (Duplicatetax3Btn.selected)
    {
        double pcntYes=(([tax3Rate doubleValue]*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        TaxValueStr=tax3Name;
       
        ProductTotalTax=[tax3Rate floatValue];
        
    }
    if (Duplicatetax1Btn.selected && Duplicatetax2Btn.selected)
    {
        double pcntYes=((([tax1Rate doubleValue]+[tax2Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name, nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        
        [taxesArray removeAllObjects],taxesArray=nil;
        ProductTotalTax=[tax1Rate floatValue]+[tax2Rate floatValue];
        
    }
    
    if (Duplicatetax1Btn.selected  && Duplicatetax3Btn.selected)
    {
        double pcntYes=((([tax1Rate doubleValue]+[tax3Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax3Name, nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
      
     
        ProductTotalTax=[tax1Rate floatValue]+[tax3Rate floatValue];
    }
    if (Duplicatetax2Btn.selected  && Duplicatetax3Btn.selected)
    {
        double pcntYes=((([tax3Rate doubleValue]+[tax2Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,tax3Name, nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        
        [taxesArray removeAllObjects],taxesArray=nil;
       
        ProductTotalTax=[tax2Rate floatValue]+[tax3Rate floatValue];
    }
    if (Duplicatetax1Btn.selected && Duplicatetax2Btn.selected && Duplicatetax3Btn.selected)
    {
        double pcntYes=((([tax1Rate doubleValue]+[tax2Rate doubleValue]+[tax3Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,tax3Name, nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        
        ProductTotalTax=[tax1Rate floatValue]+[tax2Rate floatValue]+[tax3Rate floatValue];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (Duplicatetax1Btn.selected && DuplicateBarTaxBtn.selected)
    {
        double pcntYes=(([tax1Rate doubleValue]*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        
        ProductTotalTax=[tax1Rate floatValue];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (Duplicatetax2Btn.selected && DuplicateBarTaxBtn.selected)
    {
       
        
        double pcntYes=(([tax2Rate doubleValue]*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        [taxesArray removeAllObjects],taxesArray=nil;
         ProductTotalTax=[tax2Rate floatValue];
    }
    if (Duplicatetax3Btn.selected && DuplicateBarTaxBtn.selected)
    {
       
        double pcntYes=(([tax3Rate doubleValue]*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax3Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
       
         ProductTotalTax=[tax3Rate floatValue];
    }
    if (Duplicatetax1Btn.selected && Duplicatetax2Btn.selected && DuplicateBarTaxBtn.selected)
    {
       
        double pcntYes=((([tax1Rate doubleValue]+[tax2Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        
         [taxesArray removeAllObjects],taxesArray=nil;
         ProductTotalTax=[tax2Rate floatValue]+[tax1Rate floatValue];
    }
    
    if (Duplicatetax1Btn.selected  && Duplicatetax3Btn.selected && DuplicateBarTaxBtn.selected)
    {
        
        double pcntYes=((([tax1Rate doubleValue]+[tax3Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax3Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        
        [taxesArray removeAllObjects],taxesArray=nil;
        ProductTotalTax=[tax1Rate floatValue]+[tax3Rate floatValue];
    }
    if (Duplicatetax2Btn.selected  && Duplicatetax3Btn.selected && DuplicateBarTaxBtn.selected)
    {
       
        double pcntYes=((([tax3Rate doubleValue]+[tax2Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,tax3Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        [taxesArray removeAllObjects],taxesArray=nil;
        
         ProductTotalTax=[tax3Rate floatValue]+[tax2Rate floatValue];
    }
    if (Duplicatetax1Btn.selected && Duplicatetax2Btn.selected && Duplicatetax3Btn.selected && DuplicateBarTaxBtn.selected)
    {
       
        double pcntYes=((([tax1Rate doubleValue]+[tax3Rate doubleValue]+[tax2Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,tax3Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
       
         ProductTotalTax=[tax1Rate floatValue]+[tax2Rate floatValue]+[tax3Rate floatValue];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (!Duplicatetax1Btn.selected && !Duplicatetax2Btn.selected && !Duplicatetax3Btn.selected && !DuplicateBarTaxBtn.selected)
    {
        ProductTotalTax=0;
        TaxValueStr=@"";
    }
    // //NSLog(@"tax value %@",TaxValueStr);
    totalTaxStr=[NSString stringWithFormat:@"%f",taxvalue];
   // [DuplicatePriceWithTaxBtn setTitle:totalTaxStr forState:UIControlStateNormal];
    [DuplicatePriceWithTaxBtn setTitle:[NSString stringWithFormat:@"%0.02f",taxvalue] forState:UIControlStateNormal];
}

-(void)DepartmentDuplicateBtnClicked
{
    if (DuplicateDepartmentsTable.hidden==1)
    {
        DuplicateItemNameField.hidden=YES;
        DuplicateItemNumberField.hidden=YES;
        DuplicateDepartmentsTable.hidden=NO;
        
    }
    else if (DuplicateDepartmentsTable.hidden==0)
    {
        DuplicateItemNameField.hidden=NO;
        DuplicateItemNumberField.hidden=NO;
        [DuplicateDepartmentsTable setHidden:YES];
        
    }
}

-(void)EditOptionallinfoFieldClicked:(UITextField *)sender
{
    
    NSInteger selected=sender.tag;
    
    if (selected == 100)
    {
        
        Editbonuspoint=sender.text;
    }
    if (selected == 101)
    {
        Editbarcode=sender.text;
    }
    if (selected == 102)
    {
        Editlocation=sender.text;
    }
    if (selected == 103)
    {
        
        Editunitsize=sender.text;
    }
    if (selected == 104)
    {
        
        EditUnittype=sender.text;
    }
}
-(void)SaveEditOptionalInfo
{
    [self optionalInfoViewRemove];
}
-(void)SaveEditProductNotes
{
    EditProductNotes=NotesTextView.text;
    // //NSLog(@"%@",EditProductNotes);
     [self notesViewRemove];
}
-(void)ChangeItemBtnClicked:(UIButton *)sender
{
    NSInteger selecteditem=sender.tag;
    
    if (selecteditem==100)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
            EditmodifierItem=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
            EditmodifierItem=@"yes";
        }
    }
    if (selecteditem==101)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
            EditCountthisItem=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
            EditCountthisItem=@"yes";
        }
    }
    if (selecteditem==102)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
            Editallowbuyback=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
            Editallowbuyback=@"yes";
        }
    }
    if (selecteditem==103)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
            Editprintonreceipt=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
            Editprintonreceipt=@"yes";
        }
    }
    if (selecteditem==104)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
            Editfoodstampable=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
            Editfoodstampable=@"yes";
        }
    }
    if (selecteditem==105)
    {
        if (sender.selected)
        {
            [sender setSelected:NO];
            Editpromptprice=@"no";
        }
        else if(!sender.selected)
        {
            [sender setSelected:YES];
            Editpromptprice=@"yes";
        }
    }
    
}

-(void)DepartmentChangeBtnClicked
{
    if (ChangeDepartmentsTable.hidden==1)
    {
        ChangeItemNameField.hidden=YES;
        ChangeItemNumberField.hidden=YES;
        ChangeDepartmentsTable.hidden=NO;
        
    }
    else if (ChangeDepartmentsTable.hidden==0)
    {
        ChangeItemNameField.hidden=NO;
        ChangeItemNumberField.hidden=NO;
        [ChangeDepartmentsTable setHidden:YES];
        
    }
}
-(void)ChangeAddpricingClicked
{
    if (ChangeVendorsTable.hidden==1)
    {
        ChangeInStockField.hidden=YES;
        ChangePriceWithTaxBtn.hidden=YES;
        ChangeVendorsTable.hidden=NO;
        
    }
    else if (ChangeVendorsTable.hidden==0)
    {
        ChangeInStockField.hidden=NO;
        ChangePriceWithTaxBtn.hidden=NO;
        [ChangeVendorsTable setHidden:YES];
        
    }
}
-(void)ChangeTax1Clicked
{
    if (Changetax1Btn.selected)
    {
        [Changetax1Btn setSelected:NO];
        
    }
    else if(!Changetax1Btn.selected)
    {
        [Changetax1Btn setSelected:YES];
        
    }
    [self ChangeTotaltaxmethod];
}
-(void)ChangeTax2Clikced
{
    if (Changetax2Btn.selected)
    {
        [Changetax2Btn setSelected:NO];
        
    }
    else if(!Changetax2Btn.selected)
    {
        [Changetax2Btn setSelected:YES];
        
    }
    [self ChangeTotaltaxmethod];
}
-(void)ChangeTax3Clicked
{
    if (Changetax3Btn.selected)
    {
        [Changetax3Btn setSelected:NO];
        
    }
    else if(!Changetax3Btn.selected)
    {
        [Changetax3Btn setSelected:YES];
        
    }
    [self ChangeTotaltaxmethod];
}
-(void)ChangeBarBtnClicked
{
    if (ChangeBarTaxBtn.selected)
    {
        [ChangeBarTaxBtn setSelected:NO];
        
    }
    else if(!ChangeBarTaxBtn.selected)
    {
        [ChangeBarTaxBtn setSelected:YES];
        
    }
    [self ChangeTotaltaxmethod];
}
-(void)ChangeTotaltaxmethod
{
    
    costStr=ChangePriceyouChargeField.text;

   
    if (ChangeBarTaxBtn.selected || !Changetax1Btn.selected )
    {
        taxvalue=[costStr doubleValue];
        TaxValueStr=@"Bartax";
        ProductTotalTax=0;
    }
    if (Changetax1Btn.selected)
    {
        double pcntYes=(([tax1Rate doubleValue]*[costStr doubleValue])/100);
        // //NSLog(@"%f",pcntYes);
        taxvalue=[costStr doubleValue]+pcntYes;
        TaxValueStr=tax1Name;
        
        ProductTotalTax=[tax1Rate floatValue];
        
    }
    if (Changetax2Btn.selected)
    {
        double pcntYes=(([tax2Rate doubleValue]*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        TaxValueStr=tax2Name;
        
        ProductTotalTax=[tax2Rate floatValue];
        
    }
    if (Changetax3Btn.selected)
    {
        double pcntYes=(([tax3Rate doubleValue]*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        TaxValueStr=tax3Name;
        
        ProductTotalTax=[tax3Rate floatValue];
        
    }
    if (Changetax1Btn.selected && Changetax2Btn.selected)
    {
        double pcntYes=((([tax1Rate doubleValue]+[tax2Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name, nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        
         [taxesArray removeAllObjects],taxesArray=nil;
      
        ProductTotalTax=[tax1Rate floatValue]+[tax2Rate floatValue];
        
    }
    
    if (Changetax1Btn.selected  && Changetax3Btn.selected)
    {
        double pcntYes=((([tax1Rate doubleValue]+[tax3Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax3Name, nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        
        [taxesArray removeAllObjects],taxesArray=nil;
        
        ProductTotalTax=[tax1Rate floatValue]+[tax3Rate floatValue];
    }
    if (Changetax2Btn.selected  && Changetax3Btn.selected)
    {
        double pcntYes=((([tax3Rate doubleValue]+[tax2Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,tax3Name, nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        
         [taxesArray removeAllObjects],taxesArray=nil;
        
        ProductTotalTax=[tax2Rate floatValue]+[tax3Rate floatValue];
    }
    if (Changetax1Btn.selected && Changetax2Btn.selected && Changetax3Btn.selected)
    {
        double pcntYes=((([tax1Rate doubleValue]+[tax2Rate doubleValue]+[tax3Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,tax3Name, nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        
        [taxesArray removeAllObjects],taxesArray=nil;
        ProductTotalTax=[tax1Rate floatValue]+[tax2Rate floatValue]+[tax3Rate floatValue];
        
    }
    if (Changetax1Btn.selected && ChangeBarTaxBtn.selected)
    {
        double pcntYes=(([tax1Rate doubleValue]*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
        
        ProductTotalTax=[tax1Rate floatValue];
    }
    if (Changetax2Btn.selected && ChangeBarTaxBtn.selected)
    {
        
        
        double pcntYes=(([tax2Rate doubleValue]*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
        ProductTotalTax=[tax2Rate floatValue];
    }
    if (Changetax3Btn.selected && ChangeBarTaxBtn.selected)
    {
        
        double pcntYes=(([tax3Rate doubleValue]*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax3Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
       
        ProductTotalTax=[tax3Rate floatValue];
    }
    if (Changetax1Btn.selected && Changetax2Btn.selected && ChangeBarTaxBtn.selected)
    {
        
        double pcntYes=((([tax1Rate doubleValue]+[tax2Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
       
         [taxesArray removeAllObjects],taxesArray=nil;
        ProductTotalTax=[tax1Rate floatValue]+[tax2Rate floatValue];
    }
    
    if (Changetax1Btn.selected  && Changetax3Btn.selected && ChangeBarTaxBtn.selected)
    {
        
        double pcntYes=((([tax1Rate doubleValue]+[tax3Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax3Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
       
        ProductTotalTax=[tax1Rate floatValue]+[tax3Rate floatValue];
        
    }
    if (Changetax2Btn.selected  && Changetax3Btn.selected && ChangeBarTaxBtn.selected)
    {
        
        double pcntYes=((([tax3Rate doubleValue]+[tax2Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,tax3Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        [taxesArray removeAllObjects],taxesArray=nil;
        
        ProductTotalTax=[tax3Rate floatValue]+[tax2Rate floatValue];
    }
    if (Changetax1Btn.selected && Changetax2Btn.selected && Changetax3Btn.selected && ChangeBarTaxBtn.selected)
    {
        
        double pcntYes=((([tax1Rate doubleValue]+[tax2Rate doubleValue]+[tax3Rate doubleValue])*[costStr doubleValue])/100);
        taxvalue=[costStr doubleValue]+pcntYes;
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,tax3Name,@"Bartax", nil];
        TaxValueStr=[taxesArray componentsJoinedByString:@","];
        
        ProductTotalTax=[tax1Rate floatValue]+[tax2Rate floatValue]+[tax3Rate floatValue];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (!Changetax1Btn.selected && !Changetax2Btn.selected && !Changetax3Btn.selected && !ChangeBarTaxBtn.selected)
    {
        ProductTotalTax=0;
        TaxValueStr=@"";
    }
    // //NSLog(@"tax value %@",TaxValueStr);
    totalTaxStr=[NSString stringWithFormat:@"%f",taxvalue];
    [ChangePriceWithTaxBtn setTitle:[NSString stringWithFormat:@"%0.02f",taxvalue] forState:UIControlStateNormal];
   
}
-(void)CancelChageProductData
{
     [self editProductViewremoveMethod];
}
-(void)deleteProduct:(UIButton *)sender
{
   
}

-(void)editVendor:(UIButton *)sender;
{
   
    
    
}
-(void)changeDeliveryMethodbtnClicked
{
    if (changeDeliveryTypesTable.hidden==1)
    {
        
        changeDeliveryTypesTable.hidden=NO;
        
        
    }
    else if (changeDeliveryTypesTable.hidden==0)
    {
        [changeDeliveryTypesTable setHidden:YES];
        
    }
}

-(void)ChangeGeneralinfoFieldClicked:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    if (selected == 100)
    {
        
        ChangevendorNO=sender.text;
    }
    if (selected == 101)
    {
        ChangeTerms=sender.text;
    }
    if (selected == 102)
    {
        ChangeminimumOrder=sender.text;
    }
    if (selected == 103)
    {
        
        Changecommission=sender.text;
    }
    if (selected == 104)
    {
        
        ChangeCompanyname=sender.text;
    }
    if (selected == 105)
    {
        ChangeFlatRent=sender.text;
    }
    if (selected == 106)
    {
        ChangeTaxtID=sender.text;
    }
    if (selected == 107)
    {
        
        ChangeBillable=sender.text;
    }
    if (selected == 108)
    {
        
        ChangeSocialsecurity=sender.text;
    }
    
}
-(void)ChangeAddressFieldClicked:(UITextField *)sender
{
    
    NSInteger selected=sender.tag;
    
    if (selected == 100)
    {
        
        ChangestreetAddress=sender.text;
    }
    if (selected == 101)
    {
        ChangeExtendedAddress=sender.text;
    }
    if (selected == 102)
    {
        ChangeCity=sender.text;
    }
    if (selected == 103)
    {
        
        Changestate=sender.text;
    }
    if (selected == 104)
    {
        
        ChangeZipcode=sender.text;
    }
    if (selected == 105)
    {
        Changecountry=sender.text;
    }
    if (selected == 106)
    {
        Changefirstname=sender.text;
    }
    if (selected == 107)
    {
        
        Changelastname=sender.text;
    }
    if (selected == 108)
    {
        
        ChangephNUmber=sender.text;
    }
    if (selected == 109)
    {
        Changefaxnumber=sender.text;
    }
    if (selected == 110)
    {
        
       Changeemail=sender.text;
    }
    if (selected == 111)
    {
        
        Changewebsite=sender.text;
    }
}

-(void)CancelChangeVendorData
{
     [self editVendorViewRemove];
}
-(void)editcategory:(UIButton *)sender
{
    
   
    //NSInteger  selectedrow=sender.tag;
}

-(void)CancelChangeCatedorydataClicked
{
    [self editcategoryViewremove];
    
}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    
    if (connection == CategoryConnection){
        CatresponseData = [[NSMutableData alloc] init];
    }else if (connection == VendorConnection){
        vendorResponseData = [[NSMutableData alloc] init];
    }else if (connection == SkuConnection){
        SkuResponseData = [[NSMutableData alloc] init];
    }else if (connection == ModifierConnection){
        ModifierResponseData = [[NSMutableData alloc] init];
    }else if (connection == OrderinfInfoConnection){
        OrderinfInfoResponseData = [[NSMutableData alloc] init];
    }
    
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    
    if (connection == CategoryConnection){
        [CatresponseData appendData:data];
    }else if (connection == VendorConnection){
        [vendorResponseData appendData:data];
    }else  if (connection == SkuConnection){
        [SkuResponseData appendData:data];

    }else if (connection == ModifierConnection){
        [ModifierResponseData appendData:data];

    }else if (connection == OrderinfInfoConnection){
        [OrderinfInfoResponseData appendData:data];

    }
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    if (connection == CategoryConnection){
        
        NSString *responseStr = [[NSString alloc] initWithBytes:[CatresponseData mutableBytes] length:[CatresponseData length] encoding:NSUTF8StringEncoding];
        
        NSError *error;
      dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        // //NSLog(@"%@",dataDict);
        responseStr=nil;
        NSMutableArray *deleteArray=[dataDict objectForKey:@"delete-queries"];
        NSMutableArray *insertsArray=[dataDict objectForKey:@"insert-queries"];
        
        NSMutableArray *deletesArray;
        for (int i=0; i<[deleteArray count]; i++)
        {
            NSString *foo=[deleteArray objectAtIndex:i];
            NSString* bar = [foo stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* deletestr = [bar stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletestr withArguments:deletesArray];
            
            NSString *foo2=[insertsArray objectAtIndex:i];
            NSString* bar2 = [foo2 stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* insertstr = [bar2 stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertstr withArguments:deletesArray];
        }
        
      
        
    }else if (connection == VendorConnection){
        
        NSString *responseStr = [[NSString alloc] initWithBytes:[vendorResponseData mutableBytes] length:[vendorResponseData length] encoding:NSUTF8StringEncoding];
        
        NSError *error;
      dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        // //NSLog(@"%@",dataDict);
        responseStr=nil;
        
        NSMutableArray *deleteArray=[dataDict objectForKey:@"delete-queries"];
        NSMutableArray *insertsArray=[dataDict objectForKey:@"insert-queries"];
        
        NSMutableArray *deletesArray;
        for (int i=0; i<[deleteArray count]; i++)
        {
            NSString *foo=[deleteArray objectAtIndex:i];
            NSString* bar = [foo stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* deletestr = [bar stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletestr withArguments:deletesArray];
            
            NSString *foo2=[insertsArray objectAtIndex:i];
            NSString* bar2 = [foo2 stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* insertstr = [bar2 stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertstr withArguments:deletesArray];
        }
        
       
        
    }else if (connection == SkuConnection){
        NSString *responseStr = [[NSString alloc] initWithBytes:[SkuResponseData mutableBytes] length:[SkuResponseData length] encoding:NSUTF8StringEncoding];
        
        NSError *error;
       dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        // //NSLog(@"%@",dataDict);
        responseStr=nil;
        
        NSMutableArray *deleteArray=[dataDict objectForKey:@"delete-queries"];
        NSMutableArray *insertsArray=[dataDict objectForKey:@"insert-queries"];
        
        NSMutableArray *deletesArray;
        for (int i=0; i<[deleteArray count]; i++)
        {
            NSString *foo=[deleteArray objectAtIndex:i];
            NSString* bar = [foo stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* deletestr = [bar stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletestr withArguments:deletesArray];
            
            NSString *foo2=[insertsArray objectAtIndex:i];
            NSString* bar2 = [foo2 stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* insertstr = [bar2 stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertstr withArguments:deletesArray];
        }
        
        
    }else  if (connection == ModifierConnection){
        NSString *responseStr = [[NSString alloc] initWithBytes:[ModifierResponseData mutableBytes] length:[ModifierResponseData length] encoding:NSUTF8StringEncoding];
        
        NSError *error;
       dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        // //NSLog(@"%@",dataDict);
        responseStr=nil;
        
        NSMutableArray *deleteArray=[dataDict objectForKey:@"delete-queries"];
        NSMutableArray *insertsArray=[dataDict objectForKey:@"insert-queries"];
        
        NSMutableArray *deletesArray;
        for (int i=0; i<[deleteArray count]; i++)
        {
            NSString *foo=[deleteArray objectAtIndex:i];
            NSString* bar = [foo stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* deletestr = [bar stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletestr withArguments:deletesArray];
            
            NSString *foo2=[insertsArray objectAtIndex:i];
            NSString* bar2 = [foo2 stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* insertstr = [bar2 stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertstr withArguments:deletesArray];
        }
        
     
        
    }else if (connection == OrderinfInfoConnection){
        NSString *responseStr = [[NSString alloc] initWithBytes:[OrderinfInfoResponseData mutableBytes] length:[OrderinfInfoResponseData length] encoding:NSUTF8StringEncoding];
        
        NSError *error;
        dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        // //NSLog(@"%@",dataDict);
        
        responseStr=nil;
        NSMutableArray *deleteArray=[dataDict objectForKey:@"delete-queries"];
        NSMutableArray *insertsArray=[dataDict objectForKey:@"insert-queries"];
        
        NSMutableArray *deletesArray;
        for (int i=0; i<[deleteArray count]; i++)
        {
            NSString *foo=[deleteArray objectAtIndex:i];
            NSString* bar = [foo stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* deletestr = [bar stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletestr withArguments:deletesArray];
            
            NSString *foo2=[insertsArray objectAtIndex:i];
            NSString* bar2 = [foo2 stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* insertstr = [bar2 stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertstr withArguments:deletesArray];
        }
        
      
    }
    dataDict=nil;
    
}

-(void)EditDeptprinterClicked
{
    if (ChangePrinterslistTable.hidden==1)
    {
        
        ChangePrinterslistTable.hidden=NO;
        
        ChangedeptDestextView.hidden=YES;
    }
    else if (ChangePrinterslistTable.hidden==0)
    {
        [ChangePrinterslistTable setHidden:YES];
        ChangedeptDestextView.hidden=NO;
        
    }
}
-(void)EditFoodstampableClicked
{
    if (ChangeDeptfoodstampleBtn.selected)
    {
        [ChangeDeptfoodstampleBtn setSelected:NO];
        EditDeptfoodstampable=@"no";
    }
    else if(!ChangeDeptfoodstampleBtn.selected)
    {
        [ChangeDeptfoodstampleBtn setSelected:YES];
        EditDeptfoodstampable=@"yes";
    }
    
}
-(void)EditDeptTax1Clicked
{
    if (ChangeDeptax1Btn.selected)
    {
        [ChangeDeptax1Btn setSelected:NO];
        
    }
    else if(!ChangeDeptax1Btn.selected)
    {
        [ChangeDeptax1Btn setSelected:YES];
        
    }
    [self EditDeptTotaltaxmethod];
}
-(void)EditDeptTax2Clikced
{
    if (ChangeDeptax2Btn.selected)
    {
        [ChangeDeptax2Btn setSelected:NO];
        
    }
    else if(!ChangeDeptax2Btn.selected)
    {
        [ChangeDeptax2Btn setSelected:YES];
        
    }
    [self EditDeptTotaltaxmethod];
}
-(void)EditDeptTax3Clicked
{
    if (ChangeDeptax3Btn.selected)
    {
        [ChangeDeptax3Btn setSelected:NO];
        
    }
    else if(!ChangeDeptax3Btn.selected)
    {
        [ChangeDeptax3Btn setSelected:YES];
        
    }
    [self EditDeptTotaltaxmethod];
}
-(void)EditDeptBarBtnClicked
{
    if (ChangeDepBarTaxBtn.selected)
    {
        [ChangeDepBarTaxBtn setSelected:NO];
        
    }
    else if(!ChangeDepBarTaxBtn.selected)
    {
        [ChangeDepBarTaxBtn setSelected:YES];
        
    }
    [self EditDeptTotaltaxmethod];
}
-(void)EditDeptTotaltaxmethod
{
    if (ChangeDepBarTaxBtn.selected || !ChangeDeptax1Btn.selected )
    {
        
        DepTaxValueStr=@"Bartax";
        
    }
    if (ChangeDeptax1Btn.selected)
    {
        
        DepTaxValueStr=tax1Name;
        
        
    }
    if (ChangeDeptax2Btn.selected)
    {
        
        DepTaxValueStr=tax2Name;
        
        
    }
    if (ChangeDeptax3Btn.selected)
    {
        
        DepTaxValueStr=tax3Name;
        
        
    }
    if (ChangeDeptax1Btn.selected && ChangeDeptax2Btn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name, nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
        [taxesArray removeAllObjects],taxesArray=nil;
        
    }
    
    if (ChangeDeptax1Btn.selected  && ChangeDeptax3Btn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax3Name, nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (ChangeDeptax2Btn.selected  && ChangeDeptax3Btn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,tax3Name, nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (ChangeDeptax1Btn.selected && ChangeDeptax2Btn.selected && ChangeDeptax3Btn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,tax3Name, nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (ChangeDeptax1Btn.selected && ChangeDepBarTaxBtn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (ChangeDeptax2Btn.selected && ChangeDepBarTaxBtn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (ChangeDeptax3Btn.selected && ChangeDepBarTaxBtn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax3Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (ChangeDeptax1Btn.selected && ChangeDeptax2Btn.selected && ChangeDepBarTaxBtn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    
    if (ChangeDeptax1Btn.selected  && ChangeDeptax3Btn.selected && ChangeDepBarTaxBtn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax3Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (Deptax2Btn.selected  && Deptax3Btn.selected && DepBarTaxBtn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,tax3Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (ChangeDeptax1Btn.selected && ChangeDeptax2Btn.selected && ChangeDeptax3Btn.selected && ChangeDepBarTaxBtn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,tax3Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
        
    }
    if (!ChangeDeptax1Btn.selected && !ChangeDeptax2Btn.selected && !ChangeDeptax3Btn.selected && !ChangeDepBarTaxBtn.selected)
    {
        DepTaxValueStr=@"";
    }
}

-(void)DuplicateDeptprinterClicked
{
    if (DuplicatePrinterslistTable.hidden==1)
    {
        
        DuplicatePrinterslistTable.hidden=NO;
        
        DuplicatedeptDestextView.hidden=YES;
    }else if (DuplicatePrinterslistTable.hidden==0){
        [DuplicatePrinterslistTable setHidden:YES];
        DuplicatedeptDestextView.hidden=NO;
        
    }
}
-(void)DuplicateFoodstampableClicked
{
    if (DuplicateDeptfoodstampleBtn.selected)
    {
        [DuplicateDeptfoodstampleBtn setSelected:NO];
        Deptfoodstampable=@"no";
    }else if(!DuplicateDeptfoodstampleBtn.selected){
        [DuplicateDeptfoodstampleBtn setSelected:YES];
        Deptfoodstampable=@"yes";
    }
    
}
-(void)DuplicateDeptTax1Clicked
{
    if (DuplicateDeptax1Btn.selected)
    {
        [DuplicateDeptax1Btn setSelected:NO];
        
    }else if(!DuplicateDeptax1Btn.selected){
        [DuplicateDeptax1Btn setSelected:YES];
        
    }
    [self DuplicateDeptTotaltaxmethod];
}
-(void)DuplicateDeptTax2Clikced
{
    if (DuplicateDeptax2Btn.selected)
    {
        [DuplicateDeptax2Btn setSelected:NO];
        
    }else if(!DuplicateDeptax2Btn.selected){
        [DuplicateDeptax2Btn setSelected:YES];
        
    }
    [self DuplicateDeptTotaltaxmethod];
}
-(void)DuplicateDeptTax3Clicked
{
    if (DuplicateDeptax3Btn.selected)
    {
        [DuplicateDeptax3Btn setSelected:NO];
        
    }else if(!DuplicateDeptax3Btn.selected){
        [DuplicateDeptax3Btn setSelected:YES];
        
    }
    [self DuplicateDeptTotaltaxmethod];
}
-(void)DuplicateDeptBarBtnClicked
{
    if (DuplicateDepBarTaxBtn.selected)
    {
        [DuplicateDepBarTaxBtn setSelected:NO];
        
    }else if(!DuplicateDepBarTaxBtn.selected){
        [DuplicateDepBarTaxBtn setSelected:YES];
        
    }
    [self DuplicateDeptTotaltaxmethod];
}
-(void)DuplicateDeptTotaltaxmethod
{
    if (DuplicateDepBarTaxBtn.selected || !DuplicateDeptax1Btn.selected )
    {
        
        DepTaxValueStr=@"Bartax";
        
    }
    if (DuplicateDeptax1Btn.selected)
    {
        
        DepTaxValueStr=tax1Name;
        
        
    }
    if (DuplicateDeptax2Btn.selected)
    {
        
        DepTaxValueStr=tax2Name;
        
        
    }
    if (DuplicateDeptax3Btn.selected)
    {
        
        DepTaxValueStr=tax3Name;
        
        
    }
    if (DuplicateDeptax1Btn.selected && DuplicateDeptax2Btn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name, nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
        
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    
    if (DuplicateDeptax1Btn.selected  && DuplicateDeptax3Btn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax3Name, nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (DuplicateDeptax2Btn.selected  && DuplicateDeptax3Btn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,tax3Name, nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (DuplicateDeptax1Btn.selected && DuplicateDeptax2Btn.selected && DuplicateDeptax3Btn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,tax3Name, nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (DuplicateDeptax1Btn.selected && DuplicateDepBarTaxBtn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (DuplicateDeptax2Btn.selected && DuplicateDepBarTaxBtn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (DuplicateDeptax3Btn.selected && DuplicateDepBarTaxBtn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax3Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (DuplicateDeptax1Btn.selected && DuplicateDeptax2Btn.selected && DuplicateDepBarTaxBtn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    
    if (DuplicateDeptax1Btn.selected  && DuplicateDeptax3Btn.selected && DuplicateDepBarTaxBtn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax3Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (DuplicateDeptax2Btn.selected  && DuplicateDeptax3Btn.selected && DuplicateDepBarTaxBtn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax2Name,tax3Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
    }
    if (DuplicateDeptax1Btn.selected && DuplicateDeptax2Btn.selected && DuplicateDeptax3Btn.selected && DuplicateDepBarTaxBtn.selected)
    {
        
        NSMutableArray *taxesArray = [[NSMutableArray alloc] initWithObjects:tax1Name,tax2Name,tax3Name,@"Bartax", nil];
        DepTaxValueStr=[taxesArray componentsJoinedByString:@","];
         [taxesArray removeAllObjects],taxesArray=nil;
        
    }
    if (!DuplicateDeptax1Btn.selected && !DuplicateDeptax2Btn.selected && !DuplicateDeptax3Btn.selected && !DuplicateDepBarTaxBtn.selected)
    {
        DepTaxValueStr=@"";
    }
}

-(void)CancelDuplicateDeptData
{
     [self duplicatedepartmentViewremove];
}
-(void)DuplicateCategoryforthisDept
{
    if (DuplicatecategorysListTable.hidden==1)
    {
        
        DuplicatecategorysListTable.hidden=NO;
        
        DuplicateIDfield.hidden=YES;
    }
    else if (DuplicatecategorysListTable.hidden==0)
    {
        [DuplicatecategorysListTable setHidden:YES];
        DuplicateIDfield.hidden=NO;
        
    }
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    if(textField == ChangeIDfield)
    {
        [textField resignFirstResponder];
        // Show you custom picker here....
        return NO;
    }
    
    if(textField == ChangecategoryidField)
    {
        [textField resignFirstResponder];
        // Show you custom picker here....
        return NO;
    }
    if(textField == ChangeItemNumberField)
    {
        [textField resignFirstResponder];
        // Show you custom picker here....
        return NO;
    }
    if(textField == ChangeInStockField)
    {
        [textField resignFirstResponder];
        // Show you custom picker here....
        return NO;
    }
    return YES;
}

-(void) getcategoryDatamethod
{
   
    categorynamesArray=[[NSMutableArray alloc]init];
    // categoryIdsArray=[[NSMutableArray alloc]init];
    categoryDesArray=[[NSMutableArray alloc]init];
   
    @autoreleasepool {
        for (NSDictionary *myDict in [paginationObject activeresultset])
        {
            NSString *catname=[myDict objectForKey:@"category_id"];
            NSString *catdes=[myDict objectForKey:@"category_description"];
            [categoryDesArray addObject:catdes];
            [categorynamesArray addObject:catname];
        }
    }
 

}
-(void)CancelChangeDeptData
{
    [self Editdepartmentviewremove];
}
-(void)deleteDepartment:(UIButton *)sender
{
    
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
{
    if (alertView==deletecategoryAlert && buttonIndex==0){
    
        NSString *selectedid=[categorynamesArray objectAtIndex:selectedcat];
        NSString *selectquerySQL6 = [NSString stringWithFormat:@"SELECT unique_id FROM category_details WHERE category_id='%@'",selectedid];
        NSMutableArray *selectcategorysArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:selectquerySQL6 resultsArray:selectcategorysArray];
        NSMutableArray *catuniqueidsArray=[[NSMutableArray alloc]init];
        
        for (NSDictionary *Dict in selectcategorysArray) {
            
            [catuniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }
        NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:catuniqueidsArray options:kNilOptions error:&err];
        
        // //NSLog(@"%@",jsonData);
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

       NSString *updateSQL4 =@"DELETE FROM category_details WHERE category_id=?";
        NSMutableArray *deltecatArray=[[NSMutableArray alloc]initWithObjects:selectedid, nil];
        
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL4 withArguments:deltecatArray];
        
        NSString *querySQL6 = [NSString stringWithFormat:@"SELECT category_id,category_description FROM category_details"];
        NSMutableArray *categorysArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL6 resultsArray:categorysArray];
        
        NSMutableArray *rdarray=categorysArray;
        
        //// //NSLog(@"%@",rdarray);
        //updateTableArray=[[NSMutableArray alloc] init];
        
        [paginationObject setCompleteresultset:rdarray];
        
        [paginationObject  paginationinitializer:rdarray :5];
        
        [paginationObject paginationsegment].tintColor=[UIColor whiteColor];
        [[paginationObject paginationsegment] setFrame:CGRectMake(10, addcategoryBtn.frame.size.height+10,addCategoryBackView.frame.size.width-20, 40)];
        
        [[paginationObject paginationsegment] addTarget:self action:@selector(segmentchanged:) forControlEvents:UIControlEventValueChanged];
        
        NSInteger selectedsegindex;
        selectedsegindex=0;
        [paginationObject paginationsegment].selectedSegmentIndex=selectedsegindex;
        updateTableArray=[paginationObject activateResults:selectedsegindex];
        [addCategoryBackView addSubview:[paginationObject  paginationsegment]];
        [editCategoryTable reloadData];
        updateTableArray=nil,rdarray=nil;
        if(![generalDataObject  connectedToInternet])
        {
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str,@"category_details",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet])
        {
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
        
        // //NSLog(@"%@",str);
        NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=category_details&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        // //NSLog(@"%@",str);
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
        // //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        
        
        
        CategoryConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [CategoryConnection start];
                url=nil,request=nil,string=nil;
            }
        }
        [self getcategoryDatamethod];
        str=nil,jsonData=nil,selectedid=nil;
        
    }else if (alertView==deleteDeptAlert && buttonIndex==0){
        
        NSString *selectedid=[DepartmentNamesArray objectAtIndex:selectedcat];
        
        NSString *selectquerySQL7 = [NSString stringWithFormat:@"SELECT unique_id FROM department_details WHERE department_id='%@'",selectedid];
        NSMutableArray *selectDeptsArray=[[NSMutableArray alloc]init];
        
        [[DataBaseManager dataBaseManager]execute:selectquerySQL7 resultsArray:selectDeptsArray];
        NSMutableArray *catuniqueidsArray=[[NSMutableArray alloc]init];
        
        for (NSDictionary *Dict in selectDeptsArray) {
            
            [catuniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }
        
        NSString *updateSQL =@"DELETE FROM department_printer_commands WHERE department_id=?";
        NSMutableArray *deleteprinterArray=[[NSMutableArray alloc]initWithObjects:selectedid, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL withArguments:deleteprinterArray];

        
         NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:catuniqueidsArray options:kNilOptions error:&err];
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
      
        NSString *updateSQL4 =@"DELETE FROM department_details WHERE department_id=?";
        NSMutableArray *deltecatArray=[[NSMutableArray alloc]initWithObjects:selectedid, nil];
        
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL4 withArguments:deltecatArray];
        NSString *querySQL7 = [NSString stringWithFormat:@"SELECT department_id,department_description,category_id,department_foodstampable,department_totaltax,check_value FROM department_details"];
        NSMutableArray *deptsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL7 resultsArray:deptsArray];
        
        NSMutableArray *rdarray=deptsArray;
        [jobpaginationObject setCompleteresultset:rdarray];
        
        [jobpaginationObject  paginationinitializer:rdarray :10];
        
        [jobpaginationObject paginationsegment].tintColor=[UIColor whiteColor];
        [[jobpaginationObject paginationsegment] setFrame:CGRectMake(10, addDeptbtn.frame.size.height+10,depertmentView.frame.size.width-20, 40)];
        
        [[jobpaginationObject paginationsegment] addTarget:self action:@selector(segmentchanged2:) forControlEvents:UIControlEventValueChanged];
        
        NSInteger selectedsegindex;
        selectedsegindex=0;
        [jobpaginationObject paginationsegment].selectedSegmentIndex=selectedsegindex;
        updateTableArray2=[jobpaginationObject activateResults:selectedsegindex];
        [depertmentView addSubview:[jobpaginationObject  paginationsegment]];
        [EditDeptTable reloadData];
        
        
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str,@"department_details",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        }
        else if([generalDataObject  connectedToInternet]){
        
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
        // //NSLog(@"%@",str);
        NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=department_details&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        // //NSLog(@"%@",str);
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
        // //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        VendorConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [VendorConnection start];
                  url=nil,request=nil,string=nil;
            }
        }
        [self DeptDataMethod];
        str=nil,jsonData=nil,selectedid=nil;
        
    }else if (alertView==deletevendorAlert && buttonIndex==0){
        
         NSString *selectedid=[VendornumbersArray objectAtIndex:selectedVendor];
        
        
        NSString *selectquerySQL = [NSString stringWithFormat:@"SELECT unique_id FROM vendor WHERE vendor_no='%@'",selectedid];
        NSMutableArray *selectVendorsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:selectquerySQL resultsArray:selectVendorsArray];
        NSMutableArray *catuniqueidsArray=[[NSMutableArray alloc]init];
        
        for (NSDictionary *Dict in selectVendorsArray) {
            
            [catuniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }
        NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:catuniqueidsArray options:kNilOptions error:&err];
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        
        NSString *updateSQL4 =@"DELETE FROM vendor WHERE vendor_no=?";
        NSMutableArray *deltecatArray=[[NSMutableArray alloc]initWithObjects:selectedid, nil];
        
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL4 withArguments:deltecatArray];
        
        
        NSString *querySQL = [NSString stringWithFormat: @"SELECT vendor_no,vendor_terms,vendor_min_order,vendor_commission_percent,vendor_company_name,vendor_flat_rent_rate,vendor_tax_id,vendor_billable_department,vendor_social_security_no,vendor_po_delivery_method,vendor_street_address,vendor_extended_address,vendor_city,vendor_state,vendor_zip_code,vendor_country,vendor_first_name,vendor_last_name,vendor_telephone_number,vendor_fax_number,vendor_email,vendor_website FROM vendor"];
        NSMutableArray *vendorsArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:vendorsArray];
        
        NSMutableArray *rdarray=vendorsArray;
        [vendorPaginationObject  paginationinitializer:rdarray :6];
        
        [vendorPaginationObject paginationsegment].tintColor=[UIColor whiteColor];
        [[vendorPaginationObject paginationsegment] setFrame:CGRectMake(5, AddvendorBtn.frame.size.height+10,vendorsView.frame.size.width-10, 40)];
        
        [[vendorPaginationObject paginationsegment] addTarget:self action:@selector(segmentchanged3:) forControlEvents:UIControlEventValueChanged];
        
        NSInteger selectedsegindex;
        selectedsegindex=0;
        [vendorPaginationObject paginationsegment].selectedSegmentIndex=selectedsegindex;
       [vendorPaginationObject activateResults:selectedsegindex];
        [vendorsView addSubview:[vendorPaginationObject  paginationsegment]];
        [EditVendorTable reloadData];
        
         [self vendordataMethod];
        if(![generalDataObject  connectedToInternet]){
        
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str,@"vendor",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
        // //NSLog(@"%@",str);
        NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=vendor&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        // //NSLog(@"%@",str);
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
        // //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
        VendorConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [VendorConnection start];
                  url=nil,request=nil,string=nil;
            }
        }
     
        str=nil,jsonData=nil,selectedid=nil;

    }else if (alertView==deleteProductAlert && buttonIndex==0){
        
         NSString *selectedItemNumber=[ItemNumbersArray objectAtIndex:SelectedProduct];
      
 //product data
   
        NSString *querySQL = [NSString stringWithFormat:@"SELECT unique_id FROM inventorytable WHERE inventory_item_no='%@'",selectedItemNumber];
        NSMutableArray *productDataArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:productDataArray];
        
        NSMutableArray *productuniqueidsArray=[[NSMutableArray alloc]init];
        
        for (NSDictionary *Dict in productDataArray) {
            
            [productuniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }
        NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:productuniqueidsArray options:kNilOptions error:&err];
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str,@"inventorytable",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            // //NSLog(@"%@",str);
            NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=inventorytable&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            CategoryConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [CategoryConnection start];
                  url=nil,request=nil,string=nil;
            }
        }
        
        
  //optional info data
        
        NSString *optquerySQL = [NSString stringWithFormat:@"SELECT unique_id FROM optional_info_table WHERE inventory_item_no='%@'",selectedItemNumber];
        NSMutableArray *optDataArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:optquerySQL resultsArray:optDataArray];
        NSMutableArray *optuniqueidsArray=[[NSMutableArray alloc]init];
        
        for (NSDictionary *Dict in optDataArray) {
            
            [optuniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }

        NSError *err2;
        
        NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:optuniqueidsArray options:kNilOptions error:&err2];
        
        NSString *str2=[[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str2,@"optional_info_table",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str2);
            NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=optional_info_table&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str2);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            VendorConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [VendorConnection start];
                  url=nil,request=nil,string=nil;
            }
        }
    
//all skus data
      
        NSString *skuquerySQL = [NSString stringWithFormat:@"SELECT unique_id FROM alternate_sku WHERE inventory_item_no='%@'",selectedItemNumber];
        NSMutableArray *skuDataArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:skuquerySQL resultsArray:skuDataArray];
        NSMutableArray *skuuniqueidsArray=[[NSMutableArray alloc]init];
        
        for (NSDictionary *Dict in skuDataArray) {
            
            [skuuniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }

        NSError *err3;
        
        NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:skuuniqueidsArray options:kNilOptions error:&err3];
        
        NSString *str3=[[NSString alloc] initWithData:jsonData3 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str3,@"alternate_sku",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str3);
            NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=alternate_sku&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str3 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str3);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            SkuConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [SkuConnection start];
                  url=nil,request=nil,string=nil;
                
            }
        }
        
        
  //modifier data
       
        NSString *modquerySQL = [NSString stringWithFormat:@"SELECT unique_id FROM modifier_table WHERE inventory_item_no='%@'",selectedItemNumber];
        NSMutableArray *modDataArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:modquerySQL resultsArray:modDataArray];
        NSMutableArray *moduniqueidsArray=[[NSMutableArray alloc]init];
        
        for (NSDictionary *Dict in modDataArray) {
            
            [moduniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }
        NSError *err4;
        
        NSData *jsonData4 = [NSJSONSerialization dataWithJSONObject:moduniqueidsArray options:kNilOptions error:&err4];
        
        NSString *str4=[[NSString alloc] initWithData:jsonData4 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
        
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str4,@"modifier_table",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str4);
            NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=modifier_table&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str4 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str4);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
          
            ModifierConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [ModifierConnection start];
                  url=nil,request=nil,string=nil;
            }
        }
        
 //ordering info data
        
        
        NSString *selectorderquerySQL = [NSString stringWithFormat:@"SELECT unique_id FROM ordering_info_table WHERE inventory_item_no='%@'",selectedItemNumber];
        NSMutableArray *orderuniqueArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:selectorderquerySQL resultsArray:orderuniqueArray];
        NSMutableArray *orderuniqueidsArray=[[NSMutableArray alloc]init];
        
        for (NSDictionary *Dict in orderuniqueArray) {
            
            [orderuniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }
        NSError *err5;
        
        NSData *jsonData5 = [NSJSONSerialization dataWithJSONObject:orderuniqueidsArray options:kNilOptions error:&err5];
        
        NSString *str5=[[NSString alloc] initWithData:jsonData5 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str5,@"ordering_info_table",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str5);
            NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=ordering_info_table&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str5 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str5);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
         
            OrderinfInfoConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [OrderinfInfoConnection start];
                  url=nil,request=nil,string=nil;
            }
        }
        
        NSString *deleteproductSQL =@"DELETE FROM inventorytable WHERE inventory_item_no=?";
        NSMutableArray *dleteArray=[[NSMutableArray alloc]initWithObjects:selectedItemNumber, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deleteproductSQL withArguments:dleteArray];
        
        NSString *invCountSQL = [NSString stringWithFormat:@"select count(*) as totalcount from inventorytable"];
        NSMutableArray *countArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:invCountSQL resultsArray:countArray];
        ////NSLog(@"count %@",countArray);
        NSDictionary *dict=[countArray objectAtIndex:0];
        
        int inventorycount=[[dict objectForKey:@"totalcount"] intValue];
        [productPaginationObject  ResultsPerset:inventorycount];
        if (inventorycount>0)
        {
            [ResultspersetBtn setTitle:[[productPaginationObject  ResultspersetArray] objectAtIndex:0] forState:UIControlStateNormal];
        }
        
        
          [DisplaySettable reloadData];
      
        if (  [[productPaginationObject  ResultspersetArray]  count]>0)
        {
            [ResultspersetBtn setTitle:[[productPaginationObject  ResultspersetArray] objectAtIndex:0] forState:UIControlStateNormal];
            
            SelectedResultsForSet=[[productPaginationObject  ResultspersetArray] objectAtIndex:0];
        }
        
        [self ProductpaginationMetod];
        NSString *deletesku=@"DELETE FROM alternate_sku WHERE inventory_item_no=?";
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletesku withArguments:dleteArray];
        
        NSString *updateSQL3 =@"DELETE FROM modifier_table WHERE inventory_item_no=? OR modifier_item_no=? ";
        NSMutableArray *moddeleteArray=[[NSMutableArray alloc]initWithObjects:selectedItemNumber,selectedItemNumber, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL3 withArguments:moddeleteArray];
        
        NSString *updateSQL2 =@"DELETE FROM ordering_info_table WHERE inventory_item_no=?";
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL2 withArguments:dleteArray];
        NSString *deletesql =@"DELETE FROM optional_info_table WHERE inventory_item_no=?";
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletesql withArguments:dleteArray];
        
        ModifierItemNosArray=nil;
        modifierNamesArray=nil;
        
      [self getVendorpartnumberMethod];
        str=nil,jsonData=nil,str2=nil,str3=nil,str4=nil,str5=nil,jsonData2=nil,jsonData3=nil,jsonData4=nil,jsonData5=nil,selectedItemNumber=nil;

   }
}
-(void)ChangeCategoryforthisDept
{
    if (ChangecategorysListTable.hidden==1)
    {
        
        ChangecategorysListTable.hidden=NO;
        
        ChangeIDfield.hidden=YES;
    }
    else if (ChangecategorysListTable.hidden==0)
    {
        [ChangecategorysListTable setHidden:YES];
        ChangeIDfield.hidden=NO;
        
        
    }
}
- (BOOL)shouldAutorotate
{
    // //NSLog(@"called");
    
    
    return YES;
    
    
}
-(void)updateUI
{
    
    if (isLandScope)
    {
        
        CGFloat width,height;
        
        width=1024;
        height=748;
        backgroundcolorview.frame=CGRectMake(0,y,width,height-100);
        
        
        //  sidemenu.frame=CGRectMake(0, 1,170 ,height-150);
        //sidemenu.hidden=YES;
        
        [categorybutton setFrame:CGRectMake(0.0,p,170,40)];
        navBar.frame=CGRectMake(0, 0,width , 50.0);
        
        [logoBtn setFrame:CGRectMake(60,0,250,50)];
        sationLbl.frame=CGRectMake(navBar.frame.size.width-280, 5,100, 40);
        EmpIdlbl.frame=CGRectMake(navBar.frame.size.width-193, 5,150, 40);
        Timelbl.frame=CGRectMake(navBar.frame.size.width-62, 6,80, 40);
        // mainview.frame=CGRectMake(sidemenu.frame.size.width+10,0,width-(sidemenu.frame.size.width+20),height-150);
        mainview.frame=CGRectMake(20,navBar.frame.size.height+10,width-40,height-200);
        
      
        [menubutton setFrame:CGRectMake(0,0,50,50)];
        maintoolBar.frame = CGRectMake(0, 0, mainview.frame.size.width, 40);
        
        logoimageview.frame=CGRectMake(50, (backgroundcolorview.frame.size.height)+5+y,(height-(backgroundcolorview.frame.size.height)-30), (height-(backgroundcolorview.frame.size.height)-30));
        
        [helpiconButton setFrame:CGRectMake(width-180,(backgroundcolorview.frame.size.height)+10+y,70,70)];
        
        
        [logouticonButton setFrame:CGRectMake(width-100,(backgroundcolorview.frame.size.height)+10+y,70,70)];
        
        
        CGFloat buttnwidth=(mainview.frame.size.width)/4;
        ProductBtn.frame = CGRectMake(0, 0, buttnwidth, 60);
         DepartmentsBtn.frame = CGRectMake(0, 0, buttnwidth ,60);
         CategoryBtn.frame = CGRectMake(0, 0, buttnwidth ,60);
         VendorsBtn.frame = CGRectMake(0, 0, buttnwidth ,60);
        
//category view
        
         addCategoryBackView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        
         CGFloat addbuttonwidth=(addCategoryBackView.frame.size.width-10)/2;
        addcategoryBtn.frame=CGRectMake(10, 10, addbuttonwidth, 40);
        EditCategoryBtn.frame=CGRectMake(addcategoryBtn.frame.size.width, 10, addbuttonwidth, 40);
        
        addCategoryView.frame=CGRectMake(10, addcategoryBtn.frame.size.height+10, addCategoryBackView.frame.size.width-20, addCategoryBackView.frame.size.height-20-addcategoryBtn.frame.size.height);
      
         addCategoryView.contentSize=CGSizeMake(addCategoryBackView.frame.size.width-20, addCategoryBackView.frame.size.height+100);
        CGFloat labelwidth=(addCategoryView.frame.size.width)/2;
        CGFloat x=(labelwidth/2);
        catIDlbl.frame=CGRectMake(x-40,50 ,200, 50);
        
        categoryidField.frame=CGRectMake(x+catIDlbl.frame.size.width+30, 60, 200, 40);
       
        catdesLbl.frame=CGRectMake(x-40,150 ,250, 50);
        catDesField.frame=CGRectMake(x+catIDlbl.frame.size.width+30, 130, 200, 100);
        saveCategoryBtn.frame=CGRectMake(x+catdesLbl.frame.size.width-160, 260, 80, 30);
        cancelcatBtn.frame=CGRectMake(x+catdesLbl.frame.size.width-10, 260, 80, 30);
        
        [[paginationObject paginationsegment] setFrame:CGRectMake(10, addcategoryBtn.frame.size.height+10,addCategoryBackView.frame.size.width-20, 40)];
        editCategoryTable.frame=CGRectMake(10, addcategoryBtn.frame.size.height+52, addCategoryBackView.frame.size.width-20, addCategoryBackView.frame.size.height-20-addcategoryBtn.frame.size.height-40);
        
    //edit ctaegory view
        editCatpopupview.frame=CGRectMake(0, 0, 1024, 768);
        EditCategoryView.frame=CGRectMake(50,100,editCatpopupview.frame.size.width-100,editCatpopupview.frame.size.height-200);
        CGFloat changewidth=(EditCategoryView.frame.size.width)/2;
        
        CGFloat k=(changewidth/2)+20;
        
        ChnagecatIDlbl.frame=CGRectMake(k-40,150 ,200, 50);
        
        ChangecategoryidField.frame=CGRectMake(k+ChnagecatIDlbl.frame.size.width+30, 160, 200, 40);
        ChangecatdesLbl.frame=CGRectMake(k-40,250 ,250, 50);
        
        ChengecatDesField.frame=CGRectMake(k+ChnagecatIDlbl.frame.size.width+30, 230, 200, 100);
        ChangesaveCategoryBtn.frame=CGRectMake(k+ChnagecatIDlbl.frame.size.width-140, 360, 80, 30);
        ChangecancelcatBtn.frame=CGRectMake(k+ChnagecatIDlbl.frame.size.width, 360, 80, 30);
      
        
   //department view
        depertmentView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
      
        
        CGFloat addbuttonwidth2=(depertmentView.frame.size.width-10)/2;
        addDeptbtn.frame=CGRectMake(10, 10, addbuttonwidth2, 40);
      
        Editdeptbtn.frame=CGRectMake(addDeptbtn.frame.size.width, 10, addbuttonwidth2, 40);
        
        addDepartmentView.frame=CGRectMake(10, addDeptbtn.frame.size.height+10, depertmentView.frame.size.width-20, depertmentView.frame.size.height-20-addDeptbtn.frame.size.height);
        
         addDepartmentView.contentSize=CGSizeMake(depertmentView.frame.size.width-20, depertmentView.frame.size.height+300);
        CGFloat labelwidth2=(addDepartmentView.frame.size.width)/2;
        CGFloat m=(labelwidth2/2);
    
        deptcatidlbl.frame=CGRectMake(m-100,60 ,350, 50);
        CatforthisDeptBtn.frame=CGRectMake(m+260, 70, 200, 40);
        categorysListTable.frame =CGRectMake(m+260, 110,200,100);
      
        deptIDlbl.frame=CGRectMake(m-40,150 ,250, 50);
        
        IDfield.frame=CGRectMake(m+deptIDlbl.frame.size.width+10, 160, 200, 40);
        deptdesLbl.frame=CGRectMake(m-40,250 ,280, 50);
        deptDestextView.frame=CGRectMake(m+deptIDlbl.frame.size.width+10, 230, 200, 100);
        
        Deptprinterlbl.frame=CGRectMake(m-40,350 ,280, 50);
        DeptprinterBtn.frame=CGRectMake(m+260, 360, 200, 40);
        PrinterslistTable.frame =CGRectMake(m+260, 260,200,100);
        
        DeptFoodstampablelbl.frame=CGRectMake(m-40,400 ,280, 50);
        DeptfoodstampleBtn.frame=CGRectMake(m+260, 410, 30, 30);
        Deptax1Btn.frame=CGRectMake(m-60,460,30, 30);
        
        Deptax1lbl.frame=CGRectMake(m+35-60,455,50, 40);
        Deptax2Btn.frame=CGRectMake(m+75+Deptax1lbl.frame.size.width-40,460,30, 30);
        
        Deptax2lbl.frame=CGRectMake(m+65+Deptax1lbl.frame.size.width+45-40,455,50, 40);
        
        
        Deptax3Btn.frame=CGRectMake(m+75+Deptax1lbl.frame.size.width+45-20+Deptax2lbl.frame.size.width,460,30, 30);
        
        Deptax3lbl.frame=CGRectMake(m+65+Deptax1lbl.frame.size.width+45-20+Deptax2lbl.frame.size.width+45,455,50, 40);
        DepBarTaxBtn.frame=CGRectMake(m+75+Deptax1lbl.frame.size.width+45+Deptax2lbl.frame.size.width+45+Deptax3lbl.frame.size.width,460,30, 30);
        
        Depbartaxlbl.frame=CGRectMake(m+65+Deptax1lbl.frame.size.width+45+Deptax2lbl.frame.size.width+45+Deptax3lbl.frame.size.width+45,455,80, 40);
        
        
        TimeForDeptlbl.frame=CGRectMake(m-100,520 ,350, 50);
        
        MinitBtn.frame=CGRectMake(m+260,520, 100, 40);
        
        MinitslistTable.frame = CGRectMake(m+260, 560,100,100);
        SecsBtn.frame=CGRectMake(m+370, 520, 100, 40);
        
        SecslistTable .frame= CGRectMake(m+370, 560, 100, 100);
        
        savedeptBtn.frame=CGRectMake(m+deptIDlbl.frame.size.width-180, 620, 80, 30);
        canceldeptbtn.frame=CGRectMake(m+deptIDlbl.frame.size.width-20, 620, 80, 30);

       
        
    //edit dept view
    
        [[jobpaginationObject paginationsegment] setFrame:CGRectMake(10, addDeptbtn.frame.size.height+10,depertmentView.frame.size.width-20, 40)];
        
        EditDeptTable.frame=CGRectMake(10, addDeptbtn.frame.size.height+50, depertmentView.frame.size.width-20, depertmentView.frame.size.height-20-addDeptbtn.frame.size.height-40);
        
        
        

        editDepartmentpopup.frame=CGRectMake(0, 0, 1024, 768);
        EditDepartmentView.frame=CGRectMake(50,100,editDepartmentpopup.frame.size.width-100,editDepartmentpopup.frame.size.height-200);
       
        EditDepartmentView.contentSize=CGSizeMake(editDepartmentpopup.frame.size.width-100,editDepartmentpopup.frame.size.height+100);
        CGFloat deptlblwidth=(EditDepartmentView.frame.size.width)/2;
        CGFloat b=(deptlblwidth/2);
        
        
        Changedeptcatidlbl.frame=CGRectMake(b-100,60 ,350, 50);
        ChangeCatforthisDeptBtn.frame=CGRectMake(b+260, 70, 200, 40);
        ChangecategorysListTable.frame = CGRectMake(b+260, 110,200,100);
        
        ChangedeptIDlbl.frame=CGRectMake(b-40,150 ,250, 50);
        
        ChangeIDfield.frame=CGRectMake(b+ChangedeptIDlbl.frame.size.width+10, 160, 200, 40);
        
        ChangedeptdesLbl.frame=CGRectMake(b-40,250 ,280, 50);
        
        ChangedeptDestextView.frame=CGRectMake(b+ChangedeptIDlbl.frame.size.width+10, 230, 200, 100);
        
        
        
        ChangeDeptprinterlbl.frame=CGRectMake(b-40,350 ,280, 50);
      
        ChangeDeptprinterBtn.frame=CGRectMake(b+260, 360, 200, 40);
    
        ChangePrinterslistTable.frame = CGRectMake(b+260, 260,200,100) ;
      
        ChangeDeptFoodstampablelbl.frame=CGRectMake(b-40,400 ,280, 50);
       
        
        ChangeDeptfoodstampleBtn.frame=CGRectMake(b+260, 410, 30, 30);
       
        
        ChangeDeptax1Btn.frame=CGRectMake(b-60,460,30, 30);
     
        ChangeDeptax1lbl.frame=CGRectMake(b+35-60,455,50, 40);
        
        ChangeDeptax2Btn.frame=CGRectMake(b+75+ChangeDeptax1lbl.frame.size.width-40,460,30, 30);
      
        ChangeDeptax2lbl.frame=CGRectMake(b+65+ChangeDeptax1lbl.frame.size.width+45-40,455,50, 40);
     
        
        ChangeDeptax3Btn.frame=CGRectMake(b+75+ChangeDeptax1lbl.frame.size.width+45-20+ChangeDeptax2lbl.frame.size.width,460,30, 30);
      
        ChangeDeptax3lbl.frame=CGRectMake(b+65+ChangeDeptax1lbl.frame.size.width+45-20+ChangeDeptax2lbl.frame.size.width+45,455,50, 40);
    
        
        ChangeDepBarTaxBtn.frame=CGRectMake(b+75+ChangeDeptax1lbl.frame.size.width+45+ChangeDeptax2lbl.frame.size.width+45+ChangeDeptax3lbl.frame.size.width,460,30, 30);
     
        ChangeDepbartaxlbl.frame=CGRectMake(b+65+ChangeDeptax1lbl.frame.size.width+45+ChangeDeptax2lbl.frame.size.width+45+ChangeDeptax3lbl.frame.size.width+45,455,80, 40);
        
        
        ChangeTimeForDeptlbl.frame=CGRectMake(b-100,520 ,350, 50);
      
        ChangeMinitBtn.frame=CGRectMake(b+260,520, 100, 40);
        
        ChangeMinitslistTable .frame=CGRectMake(b+260, 560,100,100);
    
        ChangeSecsBtn.frame=CGRectMake(b+370, 520, 100, 40);
       
        ChangeSecslistTable .frame=CGRectMake(b+370, 560, 100, 100);
        
        ChangesavedeptBtn.frame=CGRectMake(b+ChangedeptIDlbl.frame.size.width-180, 620, 80, 30);
        
        Changecanceldeptbtn.frame=CGRectMake(b+ChangedeptIDlbl.frame.size.width-10, 620, 80, 30);
        
        
    //Duplicate department View
        
        DuplicateDepartmentpopup.frame=CGRectMake(0, 0, 1024, 768);
      
    DuplicateDepartmentView.frame=CGRectMake(50,100,DuplicateDepartmentpopup.frame.size.width-100,DuplicateDepartmentpopup.frame.size.height-200);
   
    DuplicateDepartmentView.contentSize=CGSizeMake(DuplicateDepartmentpopup.frame.size.width-100,DuplicateDepartmentpopup.frame.size.height+200);
    
    CGFloat Dubdeptlblwidth=(DuplicateDepartmentView.frame.size.width)/2;
    CGFloat dub=(Dubdeptlblwidth/2);
    Duplicatedeptcatidlbl.frame=CGRectMake(dub-100,60 ,350, 50);
    DuplicateCatforthisDeptBtn.frame=CGRectMake(dub+260, 70, 200, 40);
     DuplicatecategorysListTable.frame = CGRectMake(dub+260, 110,200,100);
 
    DuplicatedeptIDlbl.frame=CGRectMake(dub-40,150 ,250, 50);
   
    DuplicateIDfield.frame=CGRectMake(dub+DuplicatedeptIDlbl.frame.size.width+10, 160, 200, 40);
   
    DuplicatedeptdesLbl.frame=CGRectMake(dub-40,250 ,280, 50);
   
    DuplicatedeptDestextView.frame=CGRectMake(dub+DuplicatedeptIDlbl.frame.size.width+10, 230, 200, 100);
        
        
        DuplicateDeptprinterlbl.frame=CGRectMake(dub-40,350 ,280, 50);
     
        
        DuplicateDeptprinterBtn.frame=CGRectMake(dub+260, 360, 200, 40);
       
        
        DuplicatePrinterslistTable .frame= CGRectMake(dub+260, 260,200,100);
     
        DuplicateDeptFoodstampablelbl.frame=CGRectMake(dub-40,400 ,280, 50);
       
        
        DuplicateDeptfoodstampleBtn.frame=CGRectMake(dub+260, 410, 30, 30);
      
        
        DuplicateDeptax1Btn.frame=CGRectMake(dub-60,460,30, 30);
      
        DuplicateDeptax1lbl.frame=CGRectMake(dub+35-60,455,50, 40);
      
        
        DuplicateDeptax2Btn.frame=CGRectMake(dub+75+DuplicateDeptax1lbl.frame.size.width-40,460,30, 30);
       
        DuplicateDeptax2lbl.frame=CGRectMake(dub+65+DuplicateDeptax1lbl.frame.size.width+45-40,455,50, 40);
       
        
        DuplicateDeptax3Btn.frame=CGRectMake(dub+75+DuplicateDeptax1lbl.frame.size.width+45-20+DuplicateDeptax2lbl.frame.size.width,460,30, 30);
     
        DuplicateDeptax3lbl.frame=CGRectMake(dub+65+DuplicateDeptax1lbl.frame.size.width+45-20+DuplicateDeptax2lbl.frame.size.width+45,455,50, 40);
       
        
        DuplicateDepBarTaxBtn.frame=CGRectMake(dub+75+DuplicateDeptax1lbl.frame.size.width+45+DuplicateDeptax2lbl.frame.size.width+45+DuplicateDeptax3lbl.frame.size.width,460,30, 30);
      
        DuplicateDepbartaxlbl.frame=CGRectMake(dub+65+DuplicateDeptax1lbl.frame.size.width+45+DuplicateDeptax2lbl.frame.size.width+45+Deptax3lbl.frame.size.width+45,455,80, 40);
        
        DuplicateTimeForDeptlbl.frame=CGRectMake(dub-100,520 ,350, 50);

        DuplicateMinitBtn.frame=CGRectMake(dub+260,520, 100, 40);
      
        DuplicateMinitslistTable .frame= CGRectMake(dub+260, 560,100,100);
       
        
        DuplicateSecsBtn.frame=CGRectMake(dub+370, 520, 100, 40);
      
        DuplicateSecslistTable.frame = CGRectMake(dub+370, 560, 100, 100);
      
        
        DuplicatesavedeptBtn.frame=CGRectMake(dub+DuplicatedeptIDlbl.frame.size.width-180,620, 80, 30);
       
        Duplicatecanceldeptbtn.frame=CGRectMake(dub+DuplicatedeptIDlbl.frame.size.width-10, 620, 80, 30);
    
        
 //vendors view
        vendorsView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
       
        
        CGFloat addbuttonwidth3=(vendorsView.frame.size.width-5)/2;
        AddvendorBtn.frame=CGRectMake(5, 10, addbuttonwidth3, 40);
        
        EditvendorBtn.frame=CGRectMake(AddvendorBtn.frame.size.width, 10, addbuttonwidth3, 40);
       //add vendor view
        AddvendorsView.frame=CGRectMake(5, AddvendorBtn.frame.size.height+10, vendorsView.frame.size.width-10, vendorsView.frame.size.height-20-AddvendorBtn.frame.size.height);
       
        AddvendorsView.contentSize=CGSizeMake(vendorsView.frame.size.width-10, vendorsView.frame.size.height-20-AddvendorBtn.frame.size.height+500);
       
        CGFloat fieldwidth=(AddvendorsView.frame.size.width-20)/4;
        CGFloat v=(fieldwidth/2);
       
        InfotextLbl.frame=CGRectMake(v,5 ,350, 30);
       
        AddresstextLbl.frame=CGRectMake(v+InfotextLbl.frame.size.width+150,5 ,350, 30);
        
        int d=40;
        
        for (int i=0; i<9; i++)
        {
            UILabel *mylabel=(UILabel *)[AddvendorsView viewWithTag:i+100];
            mylabel.frame=CGRectMake(v-80, d,fieldwidth+10, 40);
            [AddvendorsView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[AddvendorsView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(fieldwidth+5, d,fieldwidth-10, 40);
            [AddvendorsView addSubview:mytextfield];
            d=d+60;

        }
        polbl.frame=CGRectMake(v-80, 580,fieldwidth+10, 40);
         DeliverymethodBtn.frame=CGRectMake(fieldwidth+5, 580, fieldwidth-10, 40);
        
         DeliveryTypesTable.frame=CGRectMake(fieldwidth+5, 620,fieldwidth-10,100);
        int h=40;
        for (int i=0; i<12; i++)
        {
            
            UILabel *mylabel=(UILabel *)[AddvendorsView viewWithTag:i+100];
            mylabel.frame=CGRectMake(fieldwidth+GeneralinfoField.frame.size.width+15, h,fieldwidth+10, 40);
            [AddvendorsView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[AddvendorsView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(fieldwidth+GeneralinfoField.frame.size.width+10+mylabel.frame.size.width+5, h,fieldwidth-10, 40);
            [AddvendorsView addSubview:mytextfield];
           

            h=h+60;
            
        }

        SaveVendorsBtn.frame=CGRectMake(fieldwidth+80, 800, 80, 30);
        CancelVendorBtn.frame=CGRectMake(fieldwidth+220, 800, 80, 30);
       
        [[vendorPaginationObject paginationsegment] setFrame:CGRectMake(5, AddvendorBtn.frame.size.height+10,vendorsView.frame.size.width-10, 40)];
        
EditVendorTable.frame=CGRectMake(5, AddvendorBtn.frame.size.height+50, vendorsView.frame.size.width-10, vendorsView.frame.size.height-20-AddvendorBtn.frame.size.height-40);
        
        
   //edit vendor view
        EditVendorPopup.frame=CGRectMake(0, 0, 1024, 768);
        
        EditvendorScrollView.frame=CGRectMake(20, 40, EditVendorPopup.frame.size.width-40, EditVendorPopup.frame.size.height-80);
        EditvendorScrollView.contentSize=CGSizeMake(EditVendorPopup.frame.size.width-40, EditVendorPopup.frame.size.height-20+300);
        CGFloat fieldwidth2=(EditvendorScrollView.frame.size.width-20)/4;
        CGFloat a=(fieldwidth2/2);
        
        chnageInfotextLbl.frame=CGRectMake(a,10 ,350, 30);
        
        chnageAddresstextLbl.frame=CGRectMake(a+chnageInfotextLbl.frame.size.width+40,10 ,350, 30);
        int f=50;
        
        for (int i=0; i<9; i++)
        {
            
            
            UILabel *mylabel=(UILabel *)[EditvendorScrollView viewWithTag:i+100];
            mylabel.frame=CGRectMake(a-80, f,fieldwidth2+10, 40);
            [EditvendorScrollView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[EditvendorScrollView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(fieldwidth2+5, f,fieldwidth2-10, 40);
            [EditvendorScrollView addSubview:mytextfield];
            
            f=f+60;
            
        }
          changepolbl.frame=CGRectMake(a-80, 580,fieldwidth2+10, 40);
        changeDeliverymethodBtn.frame=CGRectMake(fieldwidth2+5, 580, fieldwidth2-10, 40);
        changeDeliveryTypesTable .frame=CGRectMake(fieldwidth2+5, 620,fieldwidth2-10,100);
        
        int g=40;
        for (int i=0; i<12; i++)
        {
            
            UILabel *mylabel=(UILabel *)[EditvendorScrollView viewWithTag:i+100];
            mylabel.frame=CGRectMake(fieldwidth2+chnageGeneralinfoField.frame.size.width+15, g,fieldwidth2+10, 40);
            [EditvendorScrollView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[EditvendorScrollView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(fieldwidth2+chnageGeneralinfoField.frame.size.width+10+mylabel.frame.size.width+5, g,fieldwidth2-10, 40);
            [EditvendorScrollView addSubview:mytextfield];
            g=g+60;
            
        }
        
        changeSaveVendorsBtn.frame=CGRectMake(fieldwidth2+80, 800, 80, 30);
        changeCancelVendorBtn.frame=CGRectMake(fieldwidth2+220, 800, 80, 30);
//product view
        
        ProductView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        CGFloat addbuttonwidth4=(ProductView.frame.size.width-5)/2;
        AddProductBtn.frame=CGRectMake(5, 10, addbuttonwidth4, 40);
        EditProductBtn.frame=CGRectMake(AddProductBtn.frame.size.width, 10, addbuttonwidth4, 40);
      
//add product view
        AddProductScrollView.frame=CGRectMake(5, AddProductBtn.frame.size.height+10, ProductView.frame.size.width-10, ProductView.frame.size.height-20-AddProductBtn.frame.size.height);
     
        AddProductScrollView.contentSize=CGSizeMake(ProductView.frame.size.width-10, ProductView.frame.size.height-20-AddProductBtn.frame.size.height+500);
        
       
        CGFloat Productfieldwidth=(AddProductScrollView.frame.size.width-100)/4;
        CGFloat r=(Productfieldwidth/2)+20;
        
        Departmentlbl.frame=CGRectMake(r-80, 30,Productfieldwidth, 50);
        DepartmentBtn.frame=CGRectMake(Productfieldwidth+5, 30, Productfieldwidth-10, 40);
       DepartmentsTable .frame=CGRectMake(Productfieldwidth+5, 70, Productfieldwidth-10, 100);
        ItemNumberlbl.frame=CGRectMake(r-80, 90,Productfieldwidth, 40);
    
        ItemNumberField.frame=CGRectMake(Productfieldwidth+5, 90,Productfieldwidth-10, 40);
        ItemNamelbl.frame=CGRectMake(r-80, 150,Productfieldwidth, 40);
       
        ItemNameField.frame=CGRectMake(Productfieldwidth+5, 150,Productfieldwidth-10, 40);
       
        Descroptionlbl.frame=CGRectMake(r-80, 210,Productfieldwidth+10, 40);
        DescriptionText.frame=CGRectMake(Productfieldwidth+5, 200,Productfieldwidth-10,80);
      
        Costlbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15, 30,Productfieldwidth+10, 40);
       
        CostField.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5, 30,Productfieldwidth-10, 40);
      
        priceyouChargelbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15,90,Productfieldwidth+10, 40);
       
        PriceyouChargeField.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,90,Productfieldwidth-10, 40);

        priceWithTaxlbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15,150,Productfieldwidth+10, 40);
        PriceWithTaxBtn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,150,Productfieldwidth-10, 40);
     
        InStocklbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15,210,Productfieldwidth+10, 40);
    
        InStockField.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,210,Productfieldwidth-10, 40);
    
        Addpricinglbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15,270,Productfieldwidth+10, 50);
        AddpricingBtn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,270,Productfieldwidth-10, 40);
         VendorsTable.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,170,Productfieldwidth-10, 100);
      
        tax1Btn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+10,35,30, 30);

        tax1lbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+45,30,50, 40);
        tax2Btn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+10,95,30, 30);
      
        tax2lbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+45,90,50, 40);
      tax3Btn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+10,155,30, 30);
     
        tax3lbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+45,150,50, 40);
        
        BarTaxBtn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+10,215,30, 30);
    
        bartaxlbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+45,210,80, 40);
        
    
        CGFloat buttonwdth=(AddProductScrollView.frame.size.width)/4;
        CGFloat xvalue=buttonwdth/4;
        for (int k=0; k<3; k++)
        {
            UIButton *mybtn=(UIButton *)[AddProductScrollView viewWithTag:k+100];
            mybtn.frame=CGRectMake(xvalue+20,350,buttonwdth+5, 40);
            [AddProductScrollView addSubview:mybtn];
            
            xvalue=xvalue+buttonwdth+15;
            
        }
        CGFloat buttonwdth2=(AddProductScrollView.frame.size.width)/4;
        CGFloat valuex=buttonwdth2/4;
        for (int j=0; j<3; j++)
        {
            
            UIButton *mybtn=(UIButton *)[AddProductScrollView viewWithTag:j+100];
            mybtn.frame=CGRectMake(valuex+20,400,buttonwdth2+5, 40);
            [AddProductScrollView addSubview:mybtn];
            
            valuex=valuex+buttonwdth2+15;
            
        }
      
        
        
       
      //edit product view
        EditProductBackView.frame=CGRectMake(5, AddProductBtn.frame.size.height+10, ProductView.frame.size.width-10, ProductView.frame.size.height-20-AddProductBtn.frame.size.height);
        
        CGFloat SearchW=(ProductView.frame.size.width-10)/2;
        CGFloat SW=SearchW/2;
        
     
        Catlbl.frame=CGRectMake(5,5,SW-20,40);
        
        CatField.frame=CGRectMake(Catlbl.frame.size.width,5,SW+15, 35);
       
        Deptlbl.frame=CGRectMake(5,45,SW-20, 40);
      
        DeptField.frame=CGRectMake(Deptlbl.frame.size.width,45,SW+15, 40);
       
        Searchlbl.frame=CGRectMake(5,90,SW-20, 40);
      
        SearchField.frame=CGRectMake(Deptlbl.frame.size.width,90,SW+15, 40);
        SearchlistTable.frame= CGRectMake(Deptlbl.frame.size.width,5,SW+15, 90);
        
        Gobtn.frame=CGRectMake(Deptlbl.frame.size.width+SearchField.frame.size.width+5,45,40, 40);
        displaylbl.frame=CGRectMake(Deptlbl.frame.size.width+SearchField.frame.size.width+5,5,SW, 40);
        
        
        ResultspersetBtn.frame=CGRectMake(Deptlbl.frame.size.width+SearchField.frame.size.width+5+displaylbl.frame.size.width,5,SW, 40);
     
        
        
        DisplaySettable.frame =CGRectMake(Deptlbl.frame.size.width+SearchField.frame.size.width+5+displaylbl.frame.size.width,45,SW, 80) ;
       
        [[productPaginationObject  paginationsegment] setFrame:CGRectMake(0,140 ,EditProductBackView.frame.size.width, 40)];
        
        
       
        editProductTable.frame=CGRectMake(0,180 ,EditProductBackView.frame.size.width, EditProductBackView.frame.size.height-180);
        
        
        SaveProductBtn.frame=CGRectMake(Productfieldwidth+140, 500, 80, 30);
        
        CancelProductBtn.frame=CGRectMake(Productfieldwidth+240, 500, 80, 30);
       // editProductTable.contentSize = CGSizeMake(editProductTable.frame.size.width+1000, editProductTable.frame.size.height+1000);
//optional info view
       
        OptionalInfoBackView.frame=CGRectMake(0,0,1024,768);
          OptionalInfoView.frame=CGRectMake(50, 50, OptionalInfoBackView.frame.size.width-100, OptionalInfoBackView.frame.size.height-100);
         // //NSLog(@"%f",OptionalInfoView.frame.origin.y);
        
        CGFloat widthfield=(OptionalInfoView.frame.size.width)/4;
        CGFloat q=(widthfield/2);
          OptionalinfoTextLbl.frame=CGRectMake(widthfield+60,10,widthfield+100, 40);
        int w=60;
        
        for (int i=0; i<5; i++)
        {
            
           
            UILabel *mylabel=(UILabel *)[OptionalInfoView viewWithTag:i+100];
            mylabel.frame=CGRectMake(q-80, w,widthfield+10, 40);
            [OptionalInfoView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[OptionalInfoView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(q+mylabel.frame.size.width-150, w,widthfield-60, 40);
            [OptionalInfoView addSubview:mytextfield];
            
            w=w+60;
            
        }
        
        OptCommissonlbl.frame=CGRectMake(q-80,360,widthfield+10, 40);
    
        optCommissionBtn.frame=CGRectMake(widthfield-30, 360,widthfield-60, 40);
     CommissionsTable .frame=CGRectMake(widthfield-30, 400,widthfield-60, 100) ;
        Alternatelbl.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width-10,60,widthfield+10, 40);
        
        AlternateTable .frame= CGRectMake(widthfield+optCommissionBtn.frame.size.width-10,95,widthfield+10, 100);
    
        AlternateTable.frame =CGRectMake(widthfield+optCommissionBtn.frame.size.width-10,95,widthfield+80, 100) ;
    
        AddskuBtn.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width+Alternatelbl.frame.size.width+80,100,widthfield-50, 80);
        
        //tagAlongitemlbl.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width+Alternatelbl.frame.size.width+10,60,widthfield+10, 40);
        
       // TagAlongitemtable.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width+Alternatelbl.frame.size.width+10,95,widthfield+10, 100);
        
        int z=210;
        for (int i=0; i<6; i++)
        {
            
            UIButton *mybtn=(UIButton *)[OptionalInfoView viewWithTag:i+100];
            mybtn.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width-10,z,30, 30);
            [OptionalInfoView addSubview:mybtn];
            
            UILabel *mylabel=(UILabel *)[OptionalInfoView viewWithTag:i+100];
            mylabel.frame=CGRectMake(widthfield+mybtn.frame.size.width+180, z-5,widthfield+10, 40);
            [OptionalInfoView addSubview:mylabel];
            
            z=z+40;
            
        }

        OptionalinfoSaveBtn.frame=CGRectMake(widthfield+120,520,80,30);
        
        OptionalinfoCancelBtn.frame=CGRectMake(widthfield+220,520,80,30);
       
        
      //Alternate skus view
        AddskupopupView.frame=CGRectMake(0, 0, 1024, 768);
  
        addskuView.frame=CGRectMake(200, 200, AddskupopupView.frame.size.width-400, AddskupopupView.frame.size.height-400);
   
       // addskuView.frame=CGRectMake(100, 300, AddskupopupView.frame.size.width-200, AddskupopupView.frame.size.height-700);
   
    
    CGFloat skuwidth=(addskuView.frame.size.width);
    
    
    skuTextlbl.frame=CGRectMake(10, 20,skuwidth-20, 100);
   
    SkuField.frame=CGRectMake(15, 100,skuwidth-30, 40);
  
    
    saveSkuBtn.frame=CGRectMake(skuwidth-400, 180, 80, 30);
  
    
    CancelSkuBtn.frame=CGRectMake(skuwidth-220, 180, 80, 30);
    
        
    //pending order view
        
        PendingOrderBackView.frame=CGRectMake(0, 0, 1024, 768);
        
        PendingOrderView.frame=CGRectMake(50, 50, PendingOrderBackView.frame.size.width-100, PendingOrderBackView.frame.size.height-100);
        
        CGFloat widthfield2=(PendingOrderView.frame.size.width)/4;
        CGFloat pen=(widthfield2/2);
        PendingOrderTextlbl.frame=CGRectMake(widthfield2+60,10,widthfield2+200, 40);
        OpenRadioBtn.frame=CGRectMake(pen-60, 60, 25, 25);
        
        openlbl.frame=CGRectMake(pen-60+OpenRadioBtn.frame.size.width+5,55,widthfield2,40);
        
        CompleteRadioBtn.frame=CGRectMake(pen-60+openlbl.frame.size.width, 60, 25, 25);
        
        completelbl.frame=CGRectMake(pen-35+openlbl.frame.size.width,55,widthfield2,40);
        
        CancelRadioBtn.frame=CGRectMake(pen-60+openlbl.frame.size.width+completelbl.frame.size.width+20, 60, 25, 25);
        
        cancellbl.frame=CGRectMake(pen-35+openlbl.frame.size.width+completelbl.frame.size.width+20,55,widthfield2,40);
        
        PendingOrdersTable.frame=CGRectMake(pen-60,95,widthfield2+550, 400);
  
        SavePendingorderBtn.frame=CGRectMake(widthfield2+40,520,80,40);
        CancelPendingorderBtn.frame=CGRectMake(widthfield2+240,520,80,40);
  //Notes View
        NotesBackView.frame=CGRectMake(0, 0, 1024, 768);
        
        NotesView.frame=CGRectMake(50, 50, NotesBackView.frame.size.width-100, NotesBackView.frame.size.height-100);
        
        CGFloat widthfield3=(NotesView.frame.size.width)/4;
        
        Notestextlbl.frame=CGRectMake(10,10,NotesView.frame.size.width-50,140);
        
        NotesTextView.frame=CGRectMake(10, 115,NotesView.frame.size.width-20,400);
        SaveNotesBtn.frame=CGRectMake(widthfield3+120,540,80,30);
        CancelNotesBtn.frame=CGRectMake(widthfield3+220,540,80,30);
//Modifier view
    
        ModifierBackView.frame=CGRectMake(0, 0, 1024, 768);
    
        ModifierView.frame=CGRectMake(50, 50, ModifierBackView.frame.size.width-100, ModifierBackView.frame.size.height-100);
        
        CGFloat widthfield4=(ModifierView.frame.size.width)/4;
        CGFloat mod=(widthfield4/2)+100;
        
        ModifierTextlbl.frame=CGRectMake(widthfield4+60,10,widthfield4+200, 40);
        
        GroupRadioBtn.frame=CGRectMake(mod, 60, 25, 25);
        
        Grouplbl.frame=CGRectMake(mod+GroupRadioBtn.frame.size.width+5,55,100,40);
        
        IndividualRadioBtn.frame=CGRectMake(mod+GroupRadioBtn.frame.size.width+Grouplbl.frame.size.width+20, 60, 25, 25);
        
        individuallbl.frame=CGRectMake(mod+GroupRadioBtn.frame.size.width+Grouplbl.frame.size.width+50,55,200,40);
        //gruop view
        ModifierGroupView.frame=CGRectMake(0,100 , ModifierView.frame.size.width, ModifierView.frame.size.height-200);
        CGFloat widthfield5=(ModifierGroupView.frame.size.width)/4;
        CGFloat group=(widthfield5/2)+100;
        
         ModifierGroupTable .frame= CGRectMake(group,0,widthfield5+450, 300);
        
       // ModifierGroupTable .frame= CGRectMake(group,0,widthfield5+300, 300);
        
        
        AddModifierGroupBtn.frame=CGRectMake(40,20,widthfield5-80,80);
        
        ModifierDeslbl.frame=CGRectMake(40,100,widthfield5,40);
        ModifierDesField.frame=CGRectMake(20, 140,widthfield5-40, 40);
        
        promptlbl.frame=CGRectMake(40,180,widthfield5,40);
        
        
        PromptField.frame=CGRectMake(20, 220,widthfield5-40, 40);
        
        Toselectlbl.frame=CGRectMake(20,290,widthfield5, 40);
        
        ToSelectBtn.frame=CGRectMake(20,320,widthfield5, 40);
        ToSelectTable .frame= CGRectMake(20,360,widthfield5, 100);
        
        ChargeforModifierBtn.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10,325,30, 30);
        
        
        chargeforModifierlbl.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10+ChargeforModifierBtn.frame.size.width+10,323,widthfield5+50, 40);
        
        
        ForceBtn.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10+ChargeforModifierBtn.frame.size.width+10+chargeforModifierlbl.frame.size.width,325,30, 30);
        
        Forcelbl.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10+ChargeforModifierBtn.frame.size.width+10+chargeforModifierlbl.frame.size.width+40,323,widthfield5, 40);
        
        SaveGroupModifierBtn.frame=CGRectMake(widthfield5+120,400,80,30);
        CancelGroupModifierBtn.frame=CGRectMake(widthfield5+220,400,80,30);
        
        
        ModIndividualView.frame=CGRectMake(0,100 , ModifierView.frame.size.width, ModifierView.frame.size.height-200);
        
        CGFloat widthfield6=(ModIndividualView.frame.size.width)/4;
        CGFloat Ind=(widthfield6/2)+100;
      
        ModifierIndividualTable .frame=CGRectMake(Ind,0,widthfield6+450, 350);
      
           // ModifierIndividualTable .frame= CGRectMake(Ind,0,widthfield6+300, 350);
            
        AddModifierBtn.frame=CGRectMake(40,130,widthfield6-80,80);
        
        SaveIndividualBtn.frame=CGRectMake(widthfield6+120,400,80,30);
       
        
        CancelIndividualBtn.frame=CGRectMake(widthfield6+220,400,80,30);
    //price levels view
        PriceLevelsBackView.frame=CGRectMake(0, 0, 1024, 768);
        PriceLevelsView.frame=CGRectMake(50, 50, PriceLevelsBackView.frame.size.width-100, PriceLevelsBackView.frame.size.height-100);
        CGFloat widthfield7=(PriceLevelsView.frame.size.width)/4;
        PriceLevelTextlbl.frame=CGRectMake(40,5,PriceLevelsView.frame.size.width-80,40);
        PriceLevelsTable.frame =CGRectMake(10,40,PriceLevelsView.frame.size.width-20, 350);
        SavePriceLevelLbl.frame=CGRectMake(widthfield7+120,420,80,30);
       CancelPricelevelbtn.frame=CGRectMake(widthfield7+220,420,80,30);
        
//ordering Info View
        
        
       
        
//edit product view
        EditproductPopUpView.frame=CGRectMake(0, 0, 1024, 768);
        
        EditProductView.frame=CGRectMake(20, 40, EditproductPopUpView.frame.size.width-40, EditproductPopUpView.frame.size.height-80);
        
        EditProductView.contentSize=CGSizeMake(EditproductPopUpView.frame.size.width-40, EditproductPopUpView.frame.size.height-20+300);
        
        CGFloat changeProductfieldwidth=(EditProductView.frame.size.width-100)/4;
        CGFloat edit=(changeProductfieldwidth/2)+20;
        
        ChangeDepartmentlbl=[[UILabel alloc] init];
        ChangeDepartmentlbl.frame=CGRectMake(edit-80, 30,changeProductfieldwidth, 50);
        
        
        
        ChangeDepartmentBtn.frame=CGRectMake(changeProductfieldwidth+5, 30, changeProductfieldwidth-10, 40);
        ChangeDepartmentsTable .frame= CGRectMake(changeProductfieldwidth+5, 70, changeProductfieldwidth-10, 100);
        
        ChangeItemNumberlbl.frame=CGRectMake(edit-80, 90,changeProductfieldwidth, 40);
        
        ChangeItemNumberField.frame=CGRectMake(changeProductfieldwidth+5, 90,changeProductfieldwidth-10, 40);
        
        ChangeItemNamelbl.frame=CGRectMake(edit-80, 150,changeProductfieldwidth, 40);
        
        ChangeItemNameField.frame=CGRectMake(changeProductfieldwidth+5, 150,changeProductfieldwidth-10, 40);
        
        ChangeDescroptionlbl.frame=CGRectMake(edit-80, 210,changeProductfieldwidth+10, 40);
        
        ChangeDescriptionText.frame=CGRectMake(changeProductfieldwidth+5, 200,changeProductfieldwidth-10,80);
        
        ChangeCostlbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+15, 30,changeProductfieldwidth+10, 40);
        
        ChangeCostField.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5, 30,changeProductfieldwidth-10, 40);
        
        ChangepriceyouChargelbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+15,90,changeProductfieldwidth+10, 40);
        
        ChangePriceyouChargeField.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5,90,changeProductfieldwidth-10, 40);
        
        ChangepriceWithTaxlbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+15,150,changeProductfieldwidth+10, 40);
        
        
        ChangePriceWithTaxBtn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5,150,changeProductfieldwidth-10, 40);
        
        ChangeInStocklbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+15,210,changeProductfieldwidth+10, 40);
        
        ChangeInStockField.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5,210,changeProductfieldwidth-10, 40);
        
        ChangeAddpricinglbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+15,270,changeProductfieldwidth+10, 50);
        
        ChangeAddpricingBtn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5,270,changeProductfieldwidth-10, 40);
        
        ChangeVendorsTable.frame = CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5,170,changeProductfieldwidth-10, 100) ;
        
        Changetax1Btn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+10,35,30, 30);
        
        Changetax1lbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+45,30,50, 40);
        Changetax2Btn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+10,95,30, 30);
        
        Changetax2lbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+45,90,50, 40);
        
        
        Changetax3Btn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+10,155,30, 30);
        
        Changetax3lbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+45,150,50, 40);
        ChangeBarTaxBtn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+10,215,30, 30);
        
        Changebartaxlbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+45,210,80, 40);
        
        CGFloat wdth=(EditProductView.frame.size.width)/4;
        CGFloat valux=wdth/4;
        for (int k=0; k<3; k++)
        {
            UIButton *mybtn=(UIButton *)[EditProductView viewWithTag:k+100];
            mybtn.frame=CGRectMake(valux+20,350,wdth+5, 40);
            [EditProductView addSubview:mybtn];
            
            
            valux=valux+wdth+15;
            
        }
        
        CGFloat wdth2=(EditProductView.frame.size.width)/4;
        CGFloat hvh=wdth2/4;
        for (int j=0; j<3; j++)
        {
            UIButton *mybtn=(UIButton *)[EditProductView viewWithTag:j+100];
            mybtn.frame=CGRectMake(hvh+20,400,wdth2+5, 40);
            [EditProductView addSubview:mybtn];
            hvh=hvh+wdth2+15;
            
        }
        
        ChangeSaveProductBtn.frame=CGRectMake(changeProductfieldwidth+130, 480, 80, 30);
        ChangeCancelProductBtn.frame=CGRectMake(changeProductfieldwidth+240, 480, 80, 30);
        
//DuplicateProduct View
        DuplicateproductPopUpView.frame=CGRectMake(0, 0, 1024, 768);
        
        DuplicateProductView.frame=CGRectMake(20, 40, DuplicateproductPopUpView.frame.size.width-40, DuplicateproductPopUpView.frame.size.height-80);
        
        DuplicateProductView.contentSize=CGSizeMake(DuplicateproductPopUpView.frame.size.width-40, DuplicateproductPopUpView.frame.size.height-20+300);
        
        CGFloat DuplicateProductfieldwidth=(DuplicateProductView.frame.size.width-100)/4;
        CGFloat Dp=(DuplicateProductfieldwidth/2)+20;
        
        
        DuplicateDepartmentlbl.frame=CGRectMake(Dp-80, 30,DuplicateProductfieldwidth, 50);
        
        DuplicateDepartmentBtn.frame=CGRectMake(DuplicateProductfieldwidth+5, 30, DuplicateProductfieldwidth-10, 40);
        DuplicateDepartmentsTable.frame = CGRectMake(DuplicateProductfieldwidth+5, 70, DuplicateProductfieldwidth-10, 100);
        
        DuplicateItemNumberlbl.frame=CGRectMake(Dp-80, 90,DuplicateProductfieldwidth, 40);
        
        DuplicateItemNumberField.frame=CGRectMake(DuplicateProductfieldwidth+5, 90,DuplicateProductfieldwidth-10, 40);
        
        DuplicateItemNamelbl.frame=CGRectMake(Dp-80, 150,DuplicateProductfieldwidth, 40);
        
        DuplicateItemNameField.frame=CGRectMake(DuplicateProductfieldwidth+5, 150,DuplicateProductfieldwidth-10, 40);
        
        DuplicateDescroptionlbl.frame=CGRectMake(Dp-80, 210,DuplicateProductfieldwidth+10, 40);
        
        DuplicateDescriptionText.frame=CGRectMake(DuplicateProductfieldwidth+5, 200,DuplicateProductfieldwidth-10,80);
        
        DuplicateCostlbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+15, 30,DuplicateProductfieldwidth+10, 40);
        
        DuplicateCostField.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5, 30,DuplicateProductfieldwidth-10, 40);
        
        DuplicatepriceyouChargelbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+15,90,DuplicateProductfieldwidth+10, 40);
        
        DuplicatePriceyouChargeField.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5,90,DuplicateProductfieldwidth-10, 40);
        
        DuplicatepriceWithTaxlbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+15,150,DuplicateProductfieldwidth+10, 40);
        
        DuplicatePriceWithTaxBtn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5,150,DuplicateProductfieldwidth-10, 40);
        
        DuplicateInStocklbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+15,210,DuplicateProductfieldwidth+10, 40);
        
        DuplicateInStockField.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5,210,DuplicateProductfieldwidth-10, 40);
        
        DuplicateAddpricinglbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+15,270,DuplicateProductfieldwidth+10, 50);
        
        DuplicateAddpricingBtn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5,270,DuplicateProductfieldwidth-10, 40);
        DuplicateVendorsTable.frame =CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5,170,DuplicateProductfieldwidth-10, 100);
        
        Duplicatetax1Btn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+10,35,30, 30);
        
        Duplicatetax1lbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+45,30,50, 40);
        
        
        Duplicatetax2Btn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+10,95,30, 30);
        
        Duplicatetax2lbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+45,90,50, 40);
        
        
        Duplicatetax3Btn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+10,155,30, 30);
        
        Duplicatetax3lbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+45,150,50, 40);
        
        
        DuplicateBarTaxBtn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+10,215,30, 30);
        
        Duplicatebartaxlbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+45,210,80, 40);
        
        CGFloat Dwdth=(DuplicateProductView.frame.size.width)/4;
        CGFloat Dvalue=Dwdth/4;
        for (int k=0; k<3; k++)
        {
            
            
            UIButton *mybtn=(UIButton *)[DuplicateProductView viewWithTag:k+100];
            mybtn.frame=CGRectMake(Dvalue+20,350,Dwdth+5, 40);
            [DuplicateProductView addSubview:mybtn];
            
            Dvalue=Dvalue+Dwdth+15;
            
        }
        
        CGFloat Dwdth2=(DuplicateProductView.frame.size.width)/4;
        CGFloat Dvaluex=Dwdth2/4;
        for (int j=0; j<3; j++)
        {
            
            UIButton *mybtn=(UIButton *)[DuplicateProductView viewWithTag:j+100];
            mybtn.frame=CGRectMake(Dvaluex+20,400,Dwdth2+5, 40);
            [DuplicateProductView addSubview:mybtn];
            
            Dvaluex=Dvaluex+Dwdth2+15;
            
        }
        
        DuplicateSaveProductBtn.frame=CGRectMake(DuplicateProductfieldwidth+130, 480, 80, 30);
        
        DuplicateCancelProductBtn.frame=CGRectMake(DuplicateProductfieldwidth+240, 480, 80, 30);
      
    //Instant Po View
        
        InstantPoPOPupView.frame=CGRectMake(0, 0, 1024, 768);
        
        InstantPOView.frame=CGRectMake(200, 200, InstantPoPOPupView.frame.size.width-400, InstantPoPOPupView.frame.size.height-400);
        
       // InstantPOView.frame=CGRectMake(150, 300, InstantPoPOPupView.frame.size.width-300, InstantPoPOPupView.frame.size.height-700);
        
        CGFloat instwidth=(InstantPOView.frame.size.width)/2;
        CGFloat inst=instwidth/2;
        
        Instantpolbl.frame=CGRectMake(inst-60, 90,instwidth-10, 50);
        InstantpoField.frame=CGRectMake(Instantpolbl.frame.size.width-40, 95,instwidth-10, 40);
        SaveInstantPoBtn.frame=CGRectMake(instwidth-90, 180, 80, 30);
        CancelInstantpoBtn.frame=CGRectMake(instwidth+40, 180, 80, 30);
        
        
        
        //present modifier view
        modBackView.frame=CGRectMake(0, 0, 1024, 768);
   
    modView.frame=CGRectMake(50, 50, modBackView.frame.size.width-100, modBackView.frame.size.height-100);

    CGFloat Modwidthfield=(modView.frame.size.width)/2;

    modTextlbl.frame=CGRectMake(Modwidthfield-100,5,Modwidthfield+200, 40);
    ModifieritemsDropdownBtn.frame=CGRectMake(20, 50,Modwidthfield-150, 40);
   
    ItemsListTable.frame = CGRectMake(20, 90,Modwidthfield-150, 200) ;
 
    modifierItemsTable .frame= CGRectMake(20+ModifieritemsDropdownBtn.frame.size.width+10, 40,modView.frame.size.width-(20+ModifieritemsDropdownBtn.frame.size.width+20), 400);

    SavemodBtn.frame=CGRectMake(Modwidthfield-100,460,80,30);
    CancelModBtn.frame=CGRectMake(Modwidthfield+30,460,80,30);
    
//Ordering info View
        
        
        OrderingInfoBackView.frame=CGRectMake(0, 0, 1024, 768);
   
    OrderingInfoView.frame=CGRectMake(50, 50, OrderingInfoBackView.frame.size.width-100, OrderingInfoBackView.frame.size.height-100);
    
  
    CGFloat Orwidth=(OrderingInfoView.frame.size.width)/4;
   
    OrderingInfotextLbl.frame=CGRectMake(Orwidth+100,10,Orwidth+100,40);
    
    Addvendorlbl.frame=CGRectMake(10, 125,Orwidth, 100);

    AddOpVendorBtn.frame=CGRectMake(Addvendorlbl.frame.size.width, 150,Orwidth+10, 40);
    
    OpVendorslistTable .frame= CGRectMake(Addvendorlbl.frame.size.width, 50,Orwidth+10, 100);
    OrderingInfoTable.frame = CGRectMake(10, 200,OrderingInfoView.frame.size.width-20, 300);
     SaveOrderingInfoBtn.frame=CGRectMake(Orwidth+120,540,80,30);
     CancelOrderingInfoBtn.frame=CGRectMake(Orwidth+220,540,80,30);
    
//Add Vendor Details View
        
        AddORVendorDetailsPopUp.frame=CGRectMake(0, 0, 1024, 768);
    AddORVendordetailsView.frame=CGRectMake(200, 100, AddORVendorDetailsPopUp.frame.size.width-400, AddORVendorDetailsPopUp.frame.size.height-250);
    
    //AddORVendordetailsView.frame=CGRectMake(100, 200, AddORVendorDetailsPopUp.frame.size.width-200, AddORVendorDetailsPopUp.frame.size.height-600);
    

    CGFloat Vendrowidth=(AddORVendordetailsView.frame.size.width)/2;
    CGFloat Vendor=Vendrowidth/2;
    
  
    AddVendorDetailsLbl.frame=CGRectMake(Vendor-40, 0,Vendrowidth-20, 100);
    

    int Ven=80;
    for (int i=0; i<4; i++)
    {
        
        UILabel *mylabel=(UILabel *)[AddORVendordetailsView viewWithTag:i+100];
        mylabel.frame=CGRectMake(Vendor-40, Ven,Vendrowidth+10, 40);
        [AddORVendordetailsView addSubview:mylabel];
        
        UITextField *mytextfield=(UITextField *)[AddORVendordetailsView viewWithTag:i+100];
        mytextfield.frame=CGRectMake(Vendor+mylabel.frame.size.width-130, Ven,Vendrowidth-60, 40);
        [AddORVendordetailsView addSubview:mytextfield];
       
        Ven=Ven+60;
        
    }
    
        Preferredlbl.frame=CGRectMake(Vendor-40, 320,Vendrowidth+10, 40);
       
        trueRadioBtn.frame=CGRectMake(Vendor+Preferredlbl.frame.size.width-130, 325,25, 25);
      
        Truelbl.frame=CGRectMake(Vendor+Preferredlbl.frame.size.width-130+42, 320,Vendrowidth-100,45 );
       
        falseRadioBtn.frame=CGRectMake(Vendor+OrVendorlbl.frame.size.width-220+Truelbl.frame.size.width, 325,25, 25);
      
        falselbl.frame=CGRectMake(Vendor+OrVendorlbl.frame.size.width-220+Truelbl.frame.size.width+42, Ven,Vendrowidth-60, 40);
        
        SaveORVendorDetailsBtn.frame=CGRectMake(Vendrowidth-80, 400, 80, 30);
        CancelORVendorDetailsBtn.frame=CGRectMake(Vendrowidth+60, 400, 80, 30);
        
        
        //product category view
        Pcategorypopup.frame=CGRectMake(0, 0, 1024, 768);
        
    // Pcategorypopup.frame=CGRectMake(0, 0, 768, 1024);
   
    PCategorysTable.frame=CGRectMake(100,200 ,Pcategorypopup.frame.size.width-200, Pcategorypopup.frame.size.height-400);
        
        
        
        Pdeaprtmentpopup.frame=CGRectMake(0, 0, 1024, 768);
    
        
       // Pdeaprtmentpopup.frame=CGRectMake(0, 0, 768, 1024);
   
    PdepartmentsTable.frame=CGRectMake(100,200 ,Pdeaprtmentpopup.frame.size.width-200, Pdeaprtmentpopup.frame.size.height-400);
  
 //sales history view
        
        HistoryPopupView.frame=CGRectMake(0, 0, 1024, 768);
    
       // HistoryPopupView.frame=CGRectMake(0, 0, 768, 1024);
   
        HistoryView.frame=CGRectMake(50, 100, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-200);
    
       // HistoryView.frame=CGRectMake(50, 150, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-400);
      
    CGFloat widthfield14=(HistoryView.frame.size.width)/4;
   
    Historytextlbl.frame=CGRectMake(widthfield14+120,10,widthfield14,40);
    
    
    SalesHistoryTable .frame= CGRectMake(10,60,HistoryView.frame.size.width-20, 400);
    saveHistoryBtn.frame=CGRectMake(widthfield14+160,500,80,30);
    
    
    }
else
    {
        CGFloat width,height;
        height=1004;
        width=768;
        // //NSLog(@" %f,%f",width,height);
        
        
        backgroundcolorview.frame=CGRectMake(0,y,width,height-100);
        navBar.frame=CGRectMake(0, 0,width , 50.0);
        
        [logoBtn setFrame:CGRectMake(60,0,250,50)];
        
        sationLbl.frame=CGRectMake(navBar.frame.size.width-280, 5,100, 40);
        EmpIdlbl.frame=CGRectMake(navBar.frame.size.width-193, 5,150, 40);
        Timelbl.frame=CGRectMake(navBar.frame.size.width-62, 6,80, 40);
        
        //sidemenu.frame=CGRectMake(0, 1,170 ,height-150);
        // sidemenu.hidden=YES;
        [categorybutton setFrame:CGRectMake(0.0,p,170,40)];
        mainview.frame=CGRectMake(20,navBar.frame.size.height+20,width-40,height-200);
        [menubutton setFrame:CGRectMake(0,0,50,50)];
        
        maintoolBar.frame = CGRectMake(0, 0, mainview.frame.size.width, 40);
        //downtoolBar.frame = CGRectMake(0, 0, mainview.frame.size.width, 40);
        
        logoimageview.frame=CGRectMake(50, (backgroundcolorview.frame.size.height)+5+y,(height-(backgroundcolorview.frame.size.height)-30), (height-(backgroundcolorview.frame.size.height)-30));
        
        [helpiconButton setFrame:CGRectMake(width-180,(backgroundcolorview.frame.size.height)+10+y,70,70)];
        
        
        [logouticonButton setFrame:CGRectMake(width-100,(backgroundcolorview.frame.size.height)+10+y,70,70)];
        
        CGFloat buttnwidth=(mainview.frame.size.width)/4;
        ProductBtn.frame = CGRectMake(0, 0, buttnwidth, 60);
        DepartmentsBtn.frame = CGRectMake(0, 0, buttnwidth ,60);
        CategoryBtn.frame = CGRectMake(0, 0, buttnwidth ,60);
        VendorsBtn.frame = CGRectMake(0, 0, buttnwidth ,60);
        
//category view
        
         addCategoryBackView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        
        CGFloat addbuttonwidth=(addCategoryBackView.frame.size.width-10)/2;
        addcategoryBtn.frame=CGRectMake(10, 10, addbuttonwidth, 40);
        EditCategoryBtn.frame=CGRectMake(addcategoryBtn.frame.size.width, 10, addbuttonwidth, 40);
        addCategoryView.frame=CGRectMake(10, addcategoryBtn.frame.size.height+10, addCategoryBackView.frame.size.width-20, addCategoryBackView.frame.size.height-20-addcategoryBtn.frame.size.height);
        
         addCategoryView.contentSize=CGSizeMake(addCategoryBackView.frame.size.width-20, addCategoryBackView.frame.size.height+100);
        CGFloat labelwidth=(addCategoryView.frame.size.width)/2;
        CGFloat x=(labelwidth/2);
        catIDlbl.frame=CGRectMake(x-40,50 ,200, 50);
        
        categoryidField.frame=CGRectMake(x+catIDlbl.frame.size.width+30, 60, 200, 40);
        
        catdesLbl.frame=CGRectMake(x-40,150 ,250, 50);
        catDesField.frame=CGRectMake(x+catIDlbl.frame.size.width+30, 130, 200, 100);
        saveCategoryBtn.frame=CGRectMake(x+catdesLbl.frame.size.width-160, 260, 80, 30);
        cancelcatBtn.frame=CGRectMake(x+catdesLbl.frame.size.width-10, 260, 80, 30);
        
        
        
        editCategoryTable.frame=CGRectMake(10, addcategoryBtn.frame.size.height, addCategoryBackView.frame.size.width-20, addCategoryBackView.frame.size.height-20-addcategoryBtn.frame.size.height);
        [[paginationObject paginationsegment] setFrame:CGRectMake(10, addcategoryBtn.frame.size.height+10,addCategoryBackView.frame.size.width-20, 40)];
        editCategoryTable.frame=CGRectMake(10, addcategoryBtn.frame.size.height+52, addCategoryBackView.frame.size.width-20, addCategoryBackView.frame.size.height-20-addcategoryBtn.frame.size.height-40);
        
         editCatpopupview.frame=CGRectMake(0, 0, 768, 1024);
     EditCategoryView.frame=CGRectMake(50,100,editCatpopupview.frame.size.width-100,editCatpopupview.frame.size.height-200);
        CGFloat changewidth=(EditCategoryView.frame.size.width)/2;
    
        CGFloat k=(changewidth/2)+20;
      
       ChnagecatIDlbl.frame=CGRectMake(k-40,150 ,200, 50);
  
        ChangecategoryidField.frame=CGRectMake(k+ChnagecatIDlbl.frame.size.width+30, 160, 200, 40);
        ChangecatdesLbl.frame=CGRectMake(k-40,250 ,250, 50);
  
       ChengecatDesField.frame=CGRectMake(k+ChnagecatIDlbl.frame.size.width+30, 230, 200, 100);
       ChangesaveCategoryBtn.frame=CGRectMake(k+ChnagecatIDlbl.frame.size.width-140, 360, 80, 30);
       ChangecancelcatBtn.frame=CGRectMake(k+ChnagecatIDlbl.frame.size.width, 360, 80, 30);
    
        
//department view
        depertmentView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        
        
        CGFloat addbuttonwidth2=(depertmentView.frame.size.width-10)/2;
        addDeptbtn.frame=CGRectMake(10, 10, addbuttonwidth2, 40);
        
        Editdeptbtn.frame=CGRectMake(addDeptbtn.frame.size.width, 10, addbuttonwidth2, 40);
        
        addDepartmentView.frame=CGRectMake(10, addDeptbtn.frame.size.height+10, depertmentView.frame.size.width-20, depertmentView.frame.size.height-20-addDeptbtn.frame.size.height);
        
         addDepartmentView.contentSize=CGSizeMake(depertmentView.frame.size.width-20, depertmentView.frame.size.height+300);
        CGFloat labelwidth2=(addDepartmentView.frame.size.width)/2;
        CGFloat m=(labelwidth2/2);
        
        deptcatidlbl.frame=CGRectMake(m-100,60 ,350, 50);
        CatforthisDeptBtn.frame=CGRectMake(m+260, 70, 200, 40);
        categorysListTable.frame =CGRectMake(m+260, 110,200,100);
        
        deptIDlbl.frame=CGRectMake(m-40,150 ,250, 50);
        
        IDfield.frame=CGRectMake(m+deptIDlbl.frame.size.width+10, 160, 200, 40);
        deptdesLbl.frame=CGRectMake(m-40,250 ,280, 50);
        deptDestextView.frame=CGRectMake(m+deptIDlbl.frame.size.width+10, 230, 200, 100);
        Deptprinterlbl.frame=CGRectMake(m-40,350 ,280, 50);
        DeptprinterBtn.frame=CGRectMake(m+260, 360, 200, 40);
        PrinterslistTable.frame =CGRectMake(m+260, 260,200,100);
        
        DeptFoodstampablelbl.frame=CGRectMake(m-40,400 ,280, 50);
        DeptfoodstampleBtn.frame=CGRectMake(m+260, 410, 30, 30);
        Deptax1Btn.frame=CGRectMake(m-60,460,30, 30);
        
        Deptax1lbl.frame=CGRectMake(m+35-60,455,50, 40);
        Deptax2Btn.frame=CGRectMake(m+75+Deptax1lbl.frame.size.width-40,460,30, 30);
        
        Deptax2lbl.frame=CGRectMake(m+65+Deptax1lbl.frame.size.width+45-40,455,50, 40);
        
        
        Deptax3Btn.frame=CGRectMake(m+75+Deptax1lbl.frame.size.width+45-20+Deptax2lbl.frame.size.width,460,30, 30);
        
        Deptax3lbl.frame=CGRectMake(m+65+Deptax1lbl.frame.size.width+45-20+Deptax2lbl.frame.size.width+45,455,50, 40);
        DepBarTaxBtn.frame=CGRectMake(m+75+Deptax1lbl.frame.size.width+45+Deptax2lbl.frame.size.width+45+Deptax3lbl.frame.size.width,460,30, 30);
        
        Depbartaxlbl.frame=CGRectMake(m+65+Deptax1lbl.frame.size.width+45+Deptax2lbl.frame.size.width+45+Deptax3lbl.frame.size.width+45,455,80, 40);
        
        
        TimeForDeptlbl.frame=CGRectMake(m-100,520 ,350, 50);
        
        MinitBtn.frame=CGRectMake(m+260,520, 100, 40);
        
        MinitslistTable.frame = CGRectMake(m+260, 560,100,100);
        SecsBtn.frame=CGRectMake(m+370, 520, 100, 40);
        
        SecslistTable .frame= CGRectMake(m+370, 560, 100, 100);
        
        savedeptBtn.frame=CGRectMake(m+deptIDlbl.frame.size.width-180, 620, 80, 30);
        canceldeptbtn.frame=CGRectMake(m+deptIDlbl.frame.size.width-20, 620, 80, 30);
        
        //edit dept view
        
        [[jobpaginationObject paginationsegment] setFrame:CGRectMake(10, addDeptbtn.frame.size.height+10,depertmentView.frame.size.width-20, 40)];
        
        EditDeptTable.frame=CGRectMake(10, addDeptbtn.frame.size.height+50, depertmentView.frame.size.width-20, depertmentView.frame.size.height-20-addDeptbtn.frame.size.height-40);
        
        
        editDepartmentpopup.frame=CGRectMake(0, 0, 768, 1024);
        EditDepartmentView.frame=CGRectMake(50,100,editDepartmentpopup.frame.size.width-100,editDepartmentpopup.frame.size.height-200);
        
        EditDepartmentView.contentSize=CGSizeMake(editDepartmentpopup.frame.size.width-100,editDepartmentpopup.frame.size.height+100);
       CGFloat deptlblwidth=(EditDepartmentView.frame.size.width)/2;
    CGFloat b=(deptlblwidth/2);
    
    
    Changedeptcatidlbl.frame=CGRectMake(b-100,60 ,350, 50);
    ChangeCatforthisDeptBtn.frame=CGRectMake(b+260, 70, 200, 40);
    ChangecategorysListTable.frame = CGRectMake(b+260, 110,200,100);
    
    ChangedeptIDlbl.frame=CGRectMake(b-40,150 ,250, 50);
   
    ChangeIDfield.frame=CGRectMake(b+ChangedeptIDlbl.frame.size.width+10, 160, 200, 40);
   
    ChangedeptdesLbl.frame=CGRectMake(b-40,250 ,280, 50);
   
    ChangedeptDestextView.frame=CGRectMake(b+ChangedeptIDlbl.frame.size.width+10, 230, 200, 100);
        ChangeDeptprinterlbl.frame=CGRectMake(b-40,350 ,280, 50);
        
        ChangeDeptprinterBtn.frame=CGRectMake(b+260, 360, 200, 40);
        
        ChangePrinterslistTable.frame = CGRectMake(b+260, 260,200,100) ;
        
        ChangeDeptFoodstampablelbl.frame=CGRectMake(b-40,400 ,280, 50);
        
        
        ChangeDeptfoodstampleBtn.frame=CGRectMake(b+260, 410, 30, 30);
        
        
        ChangeDeptax1Btn.frame=CGRectMake(b-60,460,30, 30);
        
        ChangeDeptax1lbl.frame=CGRectMake(b+35-60,455,50, 40);
        
        ChangeDeptax2Btn.frame=CGRectMake(b+75+ChangeDeptax1lbl.frame.size.width-40,460,30, 30);
        
        ChangeDeptax2lbl.frame=CGRectMake(b+65+ChangeDeptax1lbl.frame.size.width+45-40,455,50, 40);
        
        
        ChangeDeptax3Btn.frame=CGRectMake(b+75+ChangeDeptax1lbl.frame.size.width+45-20+ChangeDeptax2lbl.frame.size.width,460,30, 30);
        
        ChangeDeptax3lbl.frame=CGRectMake(b+65+ChangeDeptax1lbl.frame.size.width+45-20+ChangeDeptax2lbl.frame.size.width+45,455,50, 40);
        
        
        ChangeDepBarTaxBtn.frame=CGRectMake(b+75+ChangeDeptax1lbl.frame.size.width+45+ChangeDeptax2lbl.frame.size.width+45+ChangeDeptax3lbl.frame.size.width,460,30, 30);
        
        ChangeDepbartaxlbl.frame=CGRectMake(b+65+ChangeDeptax1lbl.frame.size.width+45+ChangeDeptax2lbl.frame.size.width+45+ChangeDeptax3lbl.frame.size.width+45,455,80, 40);
        
        ChangeTimeForDeptlbl.frame=CGRectMake(b-100,520 ,350, 50);
        
        ChangeMinitBtn.frame=CGRectMake(b+260,520, 100, 40);
        
        ChangeMinitslistTable .frame=CGRectMake(b+260, 560,100,100);
        
        ChangeSecsBtn.frame=CGRectMake(b+370, 520, 100, 40);
        
        ChangeSecslistTable .frame=CGRectMake(b+370, 560, 100, 100);
        
        ChangesavedeptBtn.frame=CGRectMake(b+ChangedeptIDlbl.frame.size.width-180, 620, 80, 30);
        
        Changecanceldeptbtn.frame=CGRectMake(b+ChangedeptIDlbl.frame.size.width-10, 620, 80, 30);
        
        
      //Duplicate department view
        
        DuplicateDepartmentpopup.frame=CGRectMake(0, 0, 768, 1024);
        
        DuplicateDepartmentView.frame=CGRectMake(50,100,DuplicateDepartmentpopup.frame.size.width-100,DuplicateDepartmentpopup.frame.size.height-200);
        
        DuplicateDepartmentView.contentSize=CGSizeMake(DuplicateDepartmentpopup.frame.size.width-100,DuplicateDepartmentpopup.frame.size.height+200);
        
        CGFloat Dubdeptlblwidth=(DuplicateDepartmentView.frame.size.width)/2;
        CGFloat dub=(Dubdeptlblwidth/2);
        Duplicatedeptcatidlbl.frame=CGRectMake(dub-100,60 ,350, 50);
        DuplicateCatforthisDeptBtn.frame=CGRectMake(dub+260, 70, 200, 40);
        DuplicatecategorysListTable.frame = CGRectMake(dub+260, 110,200,100);
        
        DuplicatedeptIDlbl.frame=CGRectMake(dub-40,150 ,250, 50);
        
        DuplicateIDfield.frame=CGRectMake(dub+DuplicatedeptIDlbl.frame.size.width+10, 160, 200, 40);
        
        DuplicatedeptdesLbl.frame=CGRectMake(dub-40,250 ,280, 50);
        
        DuplicatedeptDestextView.frame=CGRectMake(dub+DuplicatedeptIDlbl.frame.size.width+10, 230, 200, 100);
        
        DuplicateDeptprinterlbl.frame=CGRectMake(dub-40,350 ,280, 50);
        
        
        DuplicateDeptprinterBtn.frame=CGRectMake(dub+260, 360, 200, 40);
        
        
        DuplicatePrinterslistTable .frame= CGRectMake(dub+260, 260,200,100);
        
        DuplicateDeptFoodstampablelbl.frame=CGRectMake(dub-40,400 ,280, 50);
        
        
        DuplicateDeptfoodstampleBtn.frame=CGRectMake(dub+260, 410, 30, 30);
        
        
        DuplicateDeptax1Btn.frame=CGRectMake(dub-60,460,30, 30);
        
        DuplicateDeptax1lbl.frame=CGRectMake(dub+35-60,455,50, 40);
        
        
        DuplicateDeptax2Btn.frame=CGRectMake(dub+75+DuplicateDeptax1lbl.frame.size.width-40,460,30, 30);
        
        DuplicateDeptax2lbl.frame=CGRectMake(dub+65+DuplicateDeptax1lbl.frame.size.width+45-40,455,50, 40);
        
        
        DuplicateDeptax3Btn.frame=CGRectMake(dub+75+DuplicateDeptax1lbl.frame.size.width+45-20+DuplicateDeptax2lbl.frame.size.width,460,30, 30);
        
        DuplicateDeptax3lbl.frame=CGRectMake(dub+65+DuplicateDeptax1lbl.frame.size.width+45-20+DuplicateDeptax2lbl.frame.size.width+45,455,50, 40);
        
        
        DuplicateDepBarTaxBtn.frame=CGRectMake(dub+75+DuplicateDeptax1lbl.frame.size.width+45+DuplicateDeptax2lbl.frame.size.width+45+DuplicateDeptax3lbl.frame.size.width,460,30, 30);
        
        DuplicateDepbartaxlbl.frame=CGRectMake(dub+65+DuplicateDeptax1lbl.frame.size.width+45+DuplicateDeptax2lbl.frame.size.width+45+Deptax3lbl.frame.size.width+45,455,80, 40);
        
        DuplicateTimeForDeptlbl.frame=CGRectMake(dub-100,520 ,350, 50);
        
        DuplicateMinitBtn.frame=CGRectMake(dub+260,520, 100, 40);
        
        DuplicateMinitslistTable .frame= CGRectMake(dub+260, 560,100,100);
        
        
        DuplicateSecsBtn.frame=CGRectMake(dub+370, 520, 100, 40);
        
        DuplicateSecslistTable.frame = CGRectMake(dub+370, 560, 100, 100);
        
        
        DuplicatesavedeptBtn.frame=CGRectMake(dub+DuplicatedeptIDlbl.frame.size.width-180,620, 80, 30);
        
        Duplicatecanceldeptbtn.frame=CGRectMake(dub+DuplicatedeptIDlbl.frame.size.width-10, 620, 80, 30);
        
//vendors view
        vendorsView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        
        
        CGFloat addbuttonwidth3=(vendorsView.frame.size.width-5)/2;
        AddvendorBtn.frame=CGRectMake(5, 10, addbuttonwidth3, 40);
        
        EditvendorBtn.frame=CGRectMake(AddvendorBtn.frame.size.width, 10, addbuttonwidth3, 40);
    //add vendor view
        AddvendorsView.frame=CGRectMake(5, AddvendorBtn.frame.size.height+10, vendorsView.frame.size.width-10, vendorsView.frame.size.height-20-AddvendorBtn.frame.size.height);
        
        AddvendorsView.contentSize=CGSizeMake(vendorsView.frame.size.width-10, vendorsView.frame.size.height-20-AddvendorBtn.frame.size.height+500);
        
        CGFloat fieldwidth=(AddvendorsView.frame.size.width-20)/4;
        CGFloat v=(fieldwidth/2);
        
        InfotextLbl.frame=CGRectMake(v,5 ,350, 30);
        
        AddresstextLbl.frame=CGRectMake(v+InfotextLbl.frame.size.width+40,5 ,350, 30);
        
        int d=40;
        
        for (int i=0; i<9; i++)
        {
            UILabel *mylabel=(UILabel *)[AddvendorsView viewWithTag:i+100];
            mylabel.frame=CGRectMake(v-80, d,fieldwidth+10, 40);
            [AddvendorsView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[AddvendorsView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(fieldwidth+5, d,fieldwidth-10, 40);
            [AddvendorsView addSubview:mytextfield];
            d=d+60;
            
        }
        polbl.frame=CGRectMake(v-80, 580,fieldwidth+10, 40);
         DeliverymethodBtn.frame=CGRectMake(fieldwidth+5, 580, fieldwidth-10, 40);
         DeliveryTypesTable.frame=CGRectMake(fieldwidth+5, 620,fieldwidth-10,100);
        int h=40;
        for (int i=0; i<12; i++)
        {
            
            UILabel *mylabel=(UILabel *)[AddvendorsView viewWithTag:i+100];
            mylabel.frame=CGRectMake(fieldwidth+GeneralinfoField.frame.size.width+15, h,fieldwidth+10, 40);
            [AddvendorsView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[AddvendorsView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(fieldwidth+GeneralinfoField.frame.size.width+10+mylabel.frame.size.width+5, h,fieldwidth-10, 40);
            [AddvendorsView addSubview:mytextfield];
            
            
            h=h+60;
            
        }
        
        SaveVendorsBtn.frame=CGRectMake(fieldwidth+80, 800, 80,30);
        CancelVendorBtn.frame=CGRectMake(fieldwidth+220, 800, 80, 30);
        
        [[vendorPaginationObject paginationsegment] setFrame:CGRectMake(5, AddvendorBtn.frame.size.height+10,vendorsView.frame.size.width-10, 40)];
        
     EditVendorTable.frame=CGRectMake(5, AddvendorBtn.frame.size.height+50, vendorsView.frame.size.width-10, vendorsView.frame.size.height-20-AddvendorBtn.frame.size.height-40);
      
        
    //edit vendor view
        EditVendorPopup.frame=CGRectMake(0, 0, 768, 1024);
        
        EditvendorScrollView.frame=CGRectMake(20, 40, EditVendorPopup.frame.size.width-40, EditVendorPopup.frame.size.height-80);
        EditvendorScrollView.contentSize=CGSizeMake(EditVendorPopup.frame.size.width-40, EditVendorPopup.frame.size.height-20+300);
      CGFloat fieldwidth2=(EditvendorScrollView.frame.size.width-20)/4;
        CGFloat a=(fieldwidth2/2);
       
        chnageInfotextLbl.frame=CGRectMake(a,10 ,350, 30);
      
        chnageAddresstextLbl.frame=CGRectMake(a+chnageInfotextLbl.frame.size.width+40,10 ,350, 30);
              int f=50;
        
        for (int i=0; i<10; i++)
        {
            
          
            UILabel *mylabel=(UILabel *)[EditvendorScrollView viewWithTag:i+100];
            mylabel.frame=CGRectMake(a-80, f,fieldwidth2+10, 40);
            [EditvendorScrollView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[EditvendorScrollView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(fieldwidth2+5, f,fieldwidth2-10, 40);
            [EditvendorScrollView addSubview:mytextfield];
            
            f=f+60;
            
        }
          changepolbl.frame=CGRectMake(a-80, 580,fieldwidth2+10, 40);
        changeDeliverymethodBtn.frame=CGRectMake(fieldwidth2+5, 580, fieldwidth2-10, 40);
        changeDeliveryTypesTable .frame=CGRectMake(fieldwidth2+5, 620,fieldwidth2-10,100);
     
        int g=40;
        for (int i=0; i<12; i++)
        {
            
            UILabel *mylabel=(UILabel *)[EditvendorScrollView viewWithTag:i+100];
            mylabel.frame=CGRectMake(fieldwidth2+chnageGeneralinfoField.frame.size.width+15, g,fieldwidth2+10, 40);
            [EditvendorScrollView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[EditvendorScrollView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(fieldwidth2+chnageGeneralinfoField.frame.size.width+10+mylabel.frame.size.width+5, g,fieldwidth2-10, 40);
            [EditvendorScrollView addSubview:mytextfield];
            g=g+60;
            
        }
    
        changeSaveVendorsBtn.frame=CGRectMake(fieldwidth2+80, 800, 80, 30);
        changeCancelVendorBtn.frame=CGRectMake(fieldwidth2+220, 800, 80, 30);
        
//product view
        
        ProductView.frame=CGRectMake(10, (maintoolBar.frame.size.height+10), (mainview.frame.size.width)-20, (mainview.frame.size.height)-(maintoolBar.frame.size.height+20));
        CGFloat addbuttonwidth4=(ProductView.frame.size.width-5)/2;
        AddProductBtn.frame=CGRectMake(5, 10, addbuttonwidth4, 40);
        EditProductBtn.frame=CGRectMake(AddProductBtn.frame.size.width, 10, addbuttonwidth4, 40);
        
  //add product view
        AddProductScrollView.frame=CGRectMake(5, AddProductBtn.frame.size.height+10, ProductView.frame.size.width-10, ProductView.frame.size.height-20-AddProductBtn.frame.size.height);
     
        AddProductScrollView.contentSize=CGSizeMake(ProductView.frame.size.width-10, ProductView.frame.size.height-20-AddProductBtn.frame.size.height+500);
        
    
        CGFloat Productfieldwidth=(AddProductScrollView.frame.size.width-100)/4;
        CGFloat r=(Productfieldwidth/2)+20;
        
        Departmentlbl.frame=CGRectMake(r-80, 30,Productfieldwidth, 50);
        DepartmentBtn.frame=CGRectMake(Productfieldwidth+5, 30, Productfieldwidth-10, 40);
          DepartmentsTable.frame=CGRectMake(Productfieldwidth+5, 70, Productfieldwidth-10, 100);
        ItemNumberlbl.frame=CGRectMake(r-80, 90,Productfieldwidth, 40);
        
        ItemNumberField.frame=CGRectMake(Productfieldwidth+5, 90,Productfieldwidth-10, 40);
        ItemNamelbl.frame=CGRectMake(r-80, 150,Productfieldwidth, 40);
        
        ItemNameField.frame=CGRectMake(Productfieldwidth+5, 150,Productfieldwidth-10, 40);
        
        Descroptionlbl.frame=CGRectMake(r-80, 210,Productfieldwidth+10, 40);
        DescriptionText.frame=CGRectMake(Productfieldwidth+5, 200,Productfieldwidth-10,80);
        
        Costlbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15, 30,Productfieldwidth+10, 40);
        
        CostField.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5, 30,Productfieldwidth-10, 40);
        
        priceyouChargelbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15,90,Productfieldwidth+10, 40);
        
        PriceyouChargeField.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,90,Productfieldwidth-10, 40);
        
        priceWithTaxlbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15,150,Productfieldwidth+10, 40);
        PriceWithTaxBtn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,150,Productfieldwidth-10, 40);
        
        InStocklbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15,210,Productfieldwidth+10, 40);
        
        InStockField.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,210,Productfieldwidth-10, 40);
        
        Addpricinglbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+15,270,Productfieldwidth+10, 50);
        AddpricingBtn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,270,Productfieldwidth-10, 40);
         VendorsTable.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+5,170,Productfieldwidth-10, 100);
        tax1Btn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+10,35,30, 30);
        
        tax1lbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+45,30,50, 40);
        tax2Btn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+10,95,30, 30);
        
        tax2lbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+45,90,50, 40);
        tax3Btn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+10,155,30, 30);
        
        tax3lbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+45,150,50, 40);
        BarTaxBtn.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+10,215,30, 30);
        
        bartaxlbl.frame=CGRectMake(Productfieldwidth+DescriptionText.frame.size.width+10+Costlbl.frame.size.width+CostField.frame.size.width+45,210,80, 40);
        
        CGFloat buttonwdth=(AddProductScrollView.frame.size.width)/4;
        CGFloat xvalue=buttonwdth/4;
        for (int k=0; k<3; k++)
        {
            UIButton *mybtn=(UIButton *)[AddProductScrollView viewWithTag:k+100];
            mybtn.frame=CGRectMake(xvalue+20,350,buttonwdth+5, 40);
            [AddProductScrollView addSubview:mybtn];
            
            xvalue=xvalue+buttonwdth+15;
            
        }
        CGFloat buttonwdth2=(AddProductScrollView.frame.size.width)/4;
        CGFloat valuex=buttonwdth2/4;
        for (int j=0; j<3; j++)
        {
            
            UIButton *mybtn=(UIButton *)[AddProductScrollView viewWithTag:j+100];
            mybtn.frame=CGRectMake(valuex+20,400,buttonwdth2+5, 40);
            [AddProductScrollView addSubview:mybtn];
            
            valuex=valuex+buttonwdth2+15;
            
        }
        SaveProductBtn.frame=CGRectMake(Productfieldwidth+140, 500, 80, 30);
        
        CancelProductBtn.frame=CGRectMake(Productfieldwidth+240, 500, 80, 30);
        
    //edit product view
        EditProductBackView.frame=CGRectMake(5, AddProductBtn.frame.size.height+10, ProductView.frame.size.width-10, ProductView.frame.size.height-20-AddProductBtn.frame.size.height);
        
        CGFloat SearchW=(ProductView.frame.size.width-10)/2;
        CGFloat SW=SearchW/2;
        
        
        Catlbl.frame=CGRectMake(5,5,SW-20,40);
        
        CatField.frame=CGRectMake(Catlbl.frame.size.width,5,SW+15, 35);
        
        Deptlbl.frame=CGRectMake(5,45,SW-20, 40);
        
        DeptField.frame=CGRectMake(Deptlbl.frame.size.width,45,SW+15, 40);
        
        Searchlbl.frame=CGRectMake(5,90,SW-20, 40);
        
        SearchField.frame=CGRectMake(Deptlbl.frame.size.width,90,SW+15, 40);
         SearchlistTable.frame= CGRectMake(Deptlbl.frame.size.width,5,SW+15, 90);
        
        Gobtn.frame=CGRectMake(Deptlbl.frame.size.width+SearchField.frame.size.width+5,45,40, 40);
        displaylbl.frame=CGRectMake(Deptlbl.frame.size.width+SearchField.frame.size.width+5,5,SW, 40);
        
        
        ResultspersetBtn.frame=CGRectMake(Deptlbl.frame.size.width+SearchField.frame.size.width+5+displaylbl.frame.size.width,5,SW, 40);
        
        
        
        DisplaySettable.frame =CGRectMake(Deptlbl.frame.size.width+SearchField.frame.size.width+5+displaylbl.frame.size.width,45,SW, 80) ;
        
        [[productPaginationObject  paginationsegment] setFrame:CGRectMake(0,140 ,EditProductBackView.frame.size.width, 40)];
        
        
        editProductTable.frame=CGRectMake(0,180 ,EditProductBackView.frame.size.width, EditProductBackView.frame.size.height-180);

//optional info view
        OptionalInfoBackView.frame=CGRectMake(0,0,768,1024);
        OptionalInfoView.frame=CGRectMake(50, 150, OptionalInfoBackView.frame.size.width-100, OptionalInfoBackView.frame.size.height-400);
        
        CGFloat widthfield=(OptionalInfoView.frame.size.width)/4;
        CGFloat q=(widthfield/2);
          OptionalinfoTextLbl.frame=CGRectMake(widthfield+60,10,widthfield+100, 40);
        int w=60;
        
        for (int i=0; i<5; i++)
        {
            
            
            UILabel *mylabel=(UILabel *)[OptionalInfoView viewWithTag:i+100];
            mylabel.frame=CGRectMake(q-80, w,widthfield+10, 40);
            [OptionalInfoView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[OptionalInfoView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(q+mylabel.frame.size.width-130, w,widthfield-60, 40);
            [OptionalInfoView addSubview:mytextfield];
            
            w=w+60;
            
        }

        OptCommissonlbl.frame=CGRectMake(q-80,360,widthfield+10, 40);
        
        optCommissionBtn.frame=CGRectMake(widthfield-30, 360,widthfield-60, 40);
         CommissionsTable .frame=CGRectMake(widthfield-30, 400,widthfield-60, 100) ;
        Alternatelbl.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width-10,60,widthfield+10, 40);
        
        AlternateTable.frame =CGRectMake(widthfield+optCommissionBtn.frame.size.width-10,95,widthfield+80, 100) ;
        
        AddskuBtn.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width+Alternatelbl.frame.size.width+80,100,widthfield-50, 80);
        
        //tagAlongitemlbl.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width+Alternatelbl.frame.size.width+10,60,widthfield+10, 40);
        
       // TagAlongitemtable.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width+Alternatelbl.frame.size.width+10,95,widthfield+10, 100);
        
        int z=210;
        for (int i=0; i<6; i++)
        {
            
            UIButton *mybtn=(UIButton *)[OptionalInfoView viewWithTag:i+100];
            mybtn.frame=CGRectMake(widthfield+optCommissionBtn.frame.size.width-10,z,30, 30);
            [OptionalInfoView addSubview:mybtn];
            
            UILabel *mylabel=(UILabel *)[OptionalInfoView viewWithTag:i+100];
            mylabel.frame=CGRectMake(widthfield+mybtn.frame.size.width+120, z-5,widthfield+10, 40);
            [OptionalInfoView addSubview:mylabel];
            
            z=z+40;
            
        }
        OptionalinfoSaveBtn.frame=CGRectMake(widthfield+120,520,80,30);
        
        OptionalinfoCancelBtn.frame=CGRectMake(widthfield+220,520,80,30);
        
       
        
        //Alternate skus view
        AddskupopupView.frame=CGRectMake(0, 0, 768, 1024);
        
        //addskuView.frame=CGRectMake(200, 200, AddskupopupView.frame.size.width-400, AddskupopupView.frame.size.height-400);
        
         addskuView.frame=CGRectMake(100, 300, AddskupopupView.frame.size.width-200, AddskupopupView.frame.size.height-700);
    
        CGFloat skuwidth=(addskuView.frame.size.width);
        
        
        skuTextlbl.frame=CGRectMake(10, 20,skuwidth-20, 100);
        
        SkuField.frame=CGRectMake(15, 100,skuwidth-30, 40);
        
        
        saveSkuBtn.frame=CGRectMake(skuwidth-400, 180, 80, 30);
        
        CancelSkuBtn.frame=CGRectMake(skuwidth-220, 180, 80, 30);
       
   
  //pending order view
        
    PendingOrderBackView.frame=CGRectMake(0, 0, 768, 1024);

    PendingOrderView.frame=CGRectMake(50, 50, PendingOrderBackView.frame.size.width-100, PendingOrderBackView.frame.size.height-100);
    
    CGFloat widthfield2=(PendingOrderView.frame.size.width)/4;
    CGFloat pen=(widthfield2/2);
    PendingOrderTextlbl.frame=CGRectMake(widthfield2+60,10,widthfield2+200, 40);
    OpenRadioBtn.frame=CGRectMake(pen-60, 60, 25, 25);
  
    openlbl.frame=CGRectMake(pen-60+OpenRadioBtn.frame.size.width+5,55,widthfield2,40);
    CompleteRadioBtn.frame=CGRectMake(pen-60+openlbl.frame.size.width, 60, 25, 25);
  
    completelbl.frame=CGRectMake(pen-35+openlbl.frame.size.width,55,widthfield2,40);
   
    CancelRadioBtn.frame=CGRectMake(pen-60+openlbl.frame.size.width+completelbl.frame.size.width+20, 60, 25, 25);
  
    cancellbl.frame=CGRectMake(pen-35+openlbl.frame.size.width+completelbl.frame.size.width+20,55,widthfield2,40);
    
    PendingOrdersTable.frame=CGRectMake(pen-60,95,widthfield2+450, 400);
    
    SavePendingorderBtn.frame=CGRectMake(widthfield2+40,520,80,40);
       CancelPendingorderBtn.frame=CGRectMake(widthfield2+240,520,80,40);
    
  //Notes View
        NotesBackView.frame=CGRectMake(0, 0, 768, 1024);
  
    NotesView.frame=CGRectMake(50, 150, NotesBackView.frame.size.width-100, NotesBackView.frame.size.height-400);

    CGFloat widthfield3=(NotesView.frame.size.width)/4;
   
    Notestextlbl.frame=CGRectMake(10,10,NotesView.frame.size.width-50,140);
 
    NotesTextView.frame=CGRectMake(10, 115,NotesView.frame.size.width-20,400);
    SaveNotesBtn.frame=CGRectMake(widthfield3+120,540,80,30);
    CancelNotesBtn.frame=CGRectMake(widthfield3+220,540,80,30);
    
        
  //Modifier view
        
        
        ModifierBackView.frame=CGRectMake(0, 0, 768, 1024);
  
   
    ModifierView.frame=CGRectMake(50, 50, ModifierBackView.frame.size.width-100, ModifierBackView.frame.size.height-100);
    
     
    
    CGFloat widthfield4=(ModifierView.frame.size.width)/4;
    CGFloat mod=(widthfield4/2)+100;

    ModifierTextlbl.frame=CGRectMake(widthfield4+60,10,widthfield4+200, 40);
 
    GroupRadioBtn.frame=CGRectMake(mod, 60, 25, 25);
  
    Grouplbl.frame=CGRectMake(mod+GroupRadioBtn.frame.size.width+5,55,100,40);
   
    IndividualRadioBtn.frame=CGRectMake(mod+GroupRadioBtn.frame.size.width+Grouplbl.frame.size.width+20, 60, 25, 25);
   
    individuallbl.frame=CGRectMake(mod+GroupRadioBtn.frame.size.width+Grouplbl.frame.size.width+50,55,200,40);
  //gruop view
    ModifierGroupView.frame=CGRectMake(0,100 , ModifierView.frame.size.width, ModifierView.frame.size.height-200);
    CGFloat widthfield5=(ModifierGroupView.frame.size.width)/4;
    CGFloat group=(widthfield5/2)+100;
 
       // ModifierGroupTable = [[UITableView alloc] initWithFrame:CGRectMake(group,0,widthfield5+450, 300) style:UITableViewStylePlain];
 
  ModifierGroupTable .frame= CGRectMake(group,0,widthfield5+300, 300);

    
    AddModifierGroupBtn.frame=CGRectMake(40,20,widthfield5-80,80);
  
    ModifierDeslbl.frame=CGRectMake(40,100,widthfield5,40);
    ModifierDesField.frame=CGRectMake(20, 140,widthfield5-40, 40);
 
    promptlbl.frame=CGRectMake(40,180,widthfield5,40);
   
    
    PromptField.frame=CGRectMake(20, 220,widthfield5-40, 40);
   
    Toselectlbl.frame=CGRectMake(20,290,widthfield5, 40);
    
    ToSelectBtn.frame=CGRectMake(20,320,widthfield5, 40);
   ToSelectTable .frame= CGRectMake(20,360,widthfield5, 100);
    
    ChargeforModifierBtn.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10,325,30, 30);
    
   
    chargeforModifierlbl.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10+ChargeforModifierBtn.frame.size.width+10,323,widthfield5+50, 40);
    
    
    ForceBtn.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10+ChargeforModifierBtn.frame.size.width+10+chargeforModifierlbl.frame.size.width,325,30, 30);
  
    Forcelbl.frame=CGRectMake(20+ToSelectBtn.frame.size.width+10+ChargeforModifierBtn.frame.size.width+10+chargeforModifierlbl.frame.size.width+40,323,widthfield5, 40);
    
    SaveGroupModifierBtn.frame=CGRectMake(widthfield5+60,400,80,40);
    CancelGroupModifierBtn.frame=CGRectMake(widthfield5+260,400,80,40);
    
        ModIndividualView.frame=CGRectMake(0,100 , ModifierView.frame.size.width, ModifierView.frame.size.height-200);
        
        CGFloat widthfield6=(ModIndividualView.frame.size.width)/4;
        CGFloat Ind=(widthfield6/2)+100;
        
       // ModifierIndividualTable .frame=CGRectMake(Ind,0,widthfield6+450, 350);
        
         ModifierIndividualTable .frame= CGRectMake(Ind,0,widthfield6+300, 350);
        
        AddModifierBtn.frame=CGRectMake(40,130,widthfield6-80,80);
        SaveIndividualBtn.frame=CGRectMake(widthfield6+120,400,80,30);
        CancelIndividualBtn.frame=CGRectMake(widthfield6+220,400,80,30);
 //price levels view
    PriceLevelsBackView.frame=CGRectMake(0, 0, 768, 1024);
    PriceLevelsView.frame=CGRectMake(50, 50, PriceLevelsBackView.frame.size.width-100, PriceLevelsBackView.frame.size.height-100);
      CGFloat widthfield7=(PriceLevelsView.frame.size.width)/4;
    PriceLevelTextlbl.frame=CGRectMake(40,5,PriceLevelsView.frame.size.width-80,40);
    PriceLevelsTable.frame =CGRectMake(10,40,PriceLevelsView.frame.size.width-20, 350);
    SavePriceLevelLbl.frame=CGRectMake(widthfield7+60,420,80,40);
    CancelPricelevelbtn.frame=CGRectMake(widthfield7+260,420,80,40);
   
  //ordering Info View
        
     
    
        
  //edit product view
        EditproductPopUpView.frame=CGRectMake(0, 0, 768, 1024);
      
    EditProductView.frame=CGRectMake(20, 150, EditproductPopUpView.frame.size.width-40, EditproductPopUpView.frame.size.height-400);
  
    EditProductView.contentSize=CGSizeMake(EditproductPopUpView.frame.size.width-40, EditproductPopUpView.frame.size.height-20+300);
 
    CGFloat changeProductfieldwidth=(EditProductView.frame.size.width-100)/4;
    CGFloat edit=(changeProductfieldwidth/2)+20;
    
    ChangeDepartmentlbl=[[UILabel alloc] init];
    ChangeDepartmentlbl.frame=CGRectMake(edit-80, 30,changeProductfieldwidth, 50);
    
 
    
    ChangeDepartmentBtn.frame=CGRectMake(changeProductfieldwidth+5, 30, changeProductfieldwidth-10, 40);
     ChangeDepartmentsTable .frame= CGRectMake(changeProductfieldwidth+5, 70, changeProductfieldwidth-10, 100);
   
    ChangeItemNumberlbl.frame=CGRectMake(edit-80, 90,changeProductfieldwidth, 40);
  
    ChangeItemNumberField.frame=CGRectMake(changeProductfieldwidth+5, 90,changeProductfieldwidth-10, 40);
  
    ChangeItemNamelbl.frame=CGRectMake(edit-80, 150,changeProductfieldwidth, 40);
  
    ChangeItemNameField.frame=CGRectMake(changeProductfieldwidth+5, 150,changeProductfieldwidth-10, 40);
  
    ChangeDescroptionlbl.frame=CGRectMake(edit-80, 210,changeProductfieldwidth+10, 40);
  
    ChangeDescriptionText.frame=CGRectMake(changeProductfieldwidth+5, 200,changeProductfieldwidth-10,80);
  
    ChangeCostlbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+15, 30,changeProductfieldwidth+10, 40);
  
    ChangeCostField.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5, 30,changeProductfieldwidth-10, 40);
  
    ChangepriceyouChargelbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+15,90,changeProductfieldwidth+10, 40);
    
    ChangePriceyouChargeField.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5,90,changeProductfieldwidth-10, 40);
   
    ChangepriceWithTaxlbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+15,150,changeProductfieldwidth+10, 40);
  
    
    ChangePriceWithTaxBtn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5,150,changeProductfieldwidth-10, 40);
 
    ChangeInStocklbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+15,210,changeProductfieldwidth+10, 40);
 
    ChangeInStockField.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5,210,changeProductfieldwidth-10, 40);
  
    ChangeAddpricinglbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+15,270,changeProductfieldwidth+10, 50);
    
    ChangeAddpricingBtn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5,270,changeProductfieldwidth-10, 40);
    
    ChangeVendorsTable.frame = CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+5,170,changeProductfieldwidth-10, 100) ;
    
       Changetax1Btn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+10,35,30, 30);

    Changetax1lbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+45,30,50, 40);
    Changetax2Btn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+10,95,30, 30);
  
    Changetax2lbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+45,90,50, 40);
   
    
    Changetax3Btn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+10,155,30, 30);
  
    Changetax3lbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+45,150,50, 40);
    ChangeBarTaxBtn.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+10,215,30, 30);
  
    Changebartaxlbl.frame=CGRectMake(changeProductfieldwidth+ChangeDescriptionText.frame.size.width+10+ChangeCostlbl.frame.size.width+ChangeCostField.frame.size.width+45,210,80, 40);
   
        CGFloat wdth=(EditProductView.frame.size.width)/4;
        CGFloat valux=wdth/4;
        for (int k=0; k<3; k++)
        {
            UIButton *mybtn=(UIButton *)[EditProductView viewWithTag:k+100];
            mybtn.frame=CGRectMake(valux+20,350,wdth+5, 40);
            [EditProductView addSubview:mybtn];
            
            
            valux=valux+wdth+15;
            
        }
        
        CGFloat wdth2=(EditProductView.frame.size.width)/4;
        CGFloat hvh=wdth2/4;
        for (int j=0; j<3; j++)
        {
            UIButton *mybtn=(UIButton *)[EditProductView viewWithTag:j+100];
            mybtn.frame=CGRectMake(hvh+20,400,wdth2+5, 40);
            [EditProductView addSubview:mybtn];
            hvh=hvh+wdth2+15;
            
        }
    ChangeSaveProductBtn.frame=CGRectMake(changeProductfieldwidth+130, 480, 80, 30);

    ChangeCancelProductBtn.frame=CGRectMake(changeProductfieldwidth+240, 480, 80, 30);
        
//DuplicateProduct View
        DuplicateproductPopUpView.frame=CGRectMake(0, 0, 768, 1024);
   
    DuplicateProductView.frame=CGRectMake(20, 150, DuplicateproductPopUpView.frame.size.width-40, DuplicateproductPopUpView.frame.size.height-400);
   
    DuplicateProductView.contentSize=CGSizeMake(DuplicateproductPopUpView.frame.size.width-40, DuplicateproductPopUpView.frame.size.height-20+300);
   
    CGFloat DuplicateProductfieldwidth=(DuplicateProductView.frame.size.width-100)/4;
    CGFloat Dp=(DuplicateProductfieldwidth/2)+20;
    
  
    DuplicateDepartmentlbl.frame=CGRectMake(Dp-80, 30,DuplicateProductfieldwidth, 50);
    
       DuplicateDepartmentBtn.frame=CGRectMake(DuplicateProductfieldwidth+5, 30, DuplicateProductfieldwidth-10, 40);
     DuplicateDepartmentsTable.frame = CGRectMake(DuplicateProductfieldwidth+5, 70, DuplicateProductfieldwidth-10, 100);
   
    DuplicateItemNumberlbl.frame=CGRectMake(Dp-80, 90,DuplicateProductfieldwidth, 40);
    
    DuplicateItemNumberField.frame=CGRectMake(DuplicateProductfieldwidth+5, 90,DuplicateProductfieldwidth-10, 40);
   
    DuplicateItemNamelbl.frame=CGRectMake(Dp-80, 150,DuplicateProductfieldwidth, 40);
   
    DuplicateItemNameField.frame=CGRectMake(DuplicateProductfieldwidth+5, 150,DuplicateProductfieldwidth-10, 40);
   
    DuplicateDescroptionlbl.frame=CGRectMake(Dp-80, 210,DuplicateProductfieldwidth+10, 40);
   
    DuplicateDescriptionText.frame=CGRectMake(DuplicateProductfieldwidth+5, 200,DuplicateProductfieldwidth-10,80);
  
    DuplicateCostlbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+15, 30,DuplicateProductfieldwidth+10, 40);
    
    DuplicateCostField.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5, 30,DuplicateProductfieldwidth-10, 40);
   
    DuplicatepriceyouChargelbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+15,90,DuplicateProductfieldwidth+10, 40);
  
    DuplicatePriceyouChargeField.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5,90,DuplicateProductfieldwidth-10, 40);
  
    DuplicatepriceWithTaxlbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+15,150,DuplicateProductfieldwidth+10, 40);
    
    DuplicatePriceWithTaxBtn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5,150,DuplicateProductfieldwidth-10, 40);
  
    DuplicateInStocklbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+15,210,DuplicateProductfieldwidth+10, 40);
   
    DuplicateInStockField.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5,210,DuplicateProductfieldwidth-10, 40);
    
    DuplicateAddpricinglbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+15,270,DuplicateProductfieldwidth+10, 50);
    
    DuplicateAddpricingBtn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5,270,DuplicateProductfieldwidth-10, 40);
    DuplicateVendorsTable.frame =CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+5,170,DuplicateProductfieldwidth-10, 100);
    
    Duplicatetax1Btn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+10,35,30, 30);
    
    Duplicatetax1lbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+45,30,50, 40);
    
    
    Duplicatetax2Btn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+10,95,30, 30);
 
    Duplicatetax2lbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+45,90,50, 40);
    
    
    Duplicatetax3Btn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+10,155,30, 30);
    
    Duplicatetax3lbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+45,150,50, 40);
    
    
    DuplicateBarTaxBtn.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+10,215,30, 30);
    
    Duplicatebartaxlbl.frame=CGRectMake(DuplicateProductfieldwidth+DuplicateDescriptionText.frame.size.width+10+DuplicateCostlbl.frame.size.width+DuplicateCostField.frame.size.width+45,210,80, 40);
    
    CGFloat Dwdth=(DuplicateProductView.frame.size.width)/4;
    CGFloat Dvalue=Dwdth/4;
    for (int k=0; k<3; k++)
    {
      
        
        UIButton *mybtn=(UIButton *)[DuplicateProductView viewWithTag:k+100];
        mybtn.frame=CGRectMake(Dvalue+20,350,Dwdth+5, 40);
        [DuplicateProductView addSubview:mybtn];
    
        Dvalue=Dvalue+Dwdth+10;
        
    }
    
    CGFloat Dwdth2=(DuplicateProductView.frame.size.width)/4;
    CGFloat Dvaluex=Dwdth2/4;
    for (int j=0; j<3; j++)
    {
       
        UIButton *mybtn=(UIButton *)[DuplicateProductView viewWithTag:j+100];
        mybtn.frame=CGRectMake(Dvaluex+10,400,Dwdth2+5, 40);
        [DuplicateProductView addSubview:mybtn];
    
        Dvaluex=Dvaluex+Dwdth2+15;
        
    }
    
    DuplicateSaveProductBtn.frame=CGRectMake(DuplicateProductfieldwidth+130, 480, 80, 30);
    
    DuplicateCancelProductBtn.frame=CGRectMake(DuplicateProductfieldwidth+240, 480, 80, 30);
    
    //Instant Po View
        
        InstantPoPOPupView.frame=CGRectMake(0, 0, 768, 1024);
  
        //InstantPOView.frame=CGRectMake(200, 200, InstantPoPOPupView.frame.size.width-400, InstantPoPOPupView.frame.size.height-400);
   
        InstantPOView.frame=CGRectMake(150, 300, InstantPoPOPupView.frame.size.width-300, InstantPoPOPupView.frame.size.height-700);
   
    CGFloat instwidth=(InstantPOView.frame.size.width)/2;
    CGFloat inst=instwidth/2;
   
    Instantpolbl.frame=CGRectMake(inst-60, 90,instwidth-10, 50);
    InstantpoField.frame=CGRectMake(Instantpolbl.frame.size.width-40, 95,instwidth-10, 40);
    SaveInstantPoBtn.frame=CGRectMake(instwidth-90, 180, 80, 30);
   CancelInstantpoBtn.frame=CGRectMake(instwidth+40, 180, 80, 30);
    
        
        
        
//present modifier view
        modBackView.frame=CGRectMake(0, 0, 768, 1024);
        
        modView.frame=CGRectMake(50, 150, modBackView.frame.size.width-100, modBackView.frame.size.height-400);
        
        CGFloat Modwidthfield=(modView.frame.size.width)/2;
        
        modTextlbl.frame=CGRectMake(Modwidthfield-100,5,Modwidthfield+200, 40);
        ModifieritemsDropdownBtn.frame=CGRectMake(20, 50,Modwidthfield-150, 40);
        
        ItemsListTable.frame = CGRectMake(20, 90,Modwidthfield-150, 200) ;
        
        modifierItemsTable .frame= CGRectMake(20+ModifieritemsDropdownBtn.frame.size.width+10, 40,modView.frame.size.width-(20+ModifieritemsDropdownBtn.frame.size.width+20), 400);
        
        SavemodBtn.frame=CGRectMake(Modwidthfield-100,460,80,30);
        CancelModBtn.frame=CGRectMake(Modwidthfield+30,460,80,30);
        
//Ordering info View
        
        
        OrderingInfoBackView.frame=CGRectMake(0, 0, 768, 1024);
        
        OrderingInfoView.frame=CGRectMake(50, 150, OrderingInfoBackView.frame.size.width-100, OrderingInfoBackView.frame.size.height-400);
        
        
        CGFloat Orwidth=(OrderingInfoView.frame.size.width)/4;
        
        OrderingInfotextLbl.frame=CGRectMake(Orwidth+100,10,Orwidth+100,40);
        
        Addvendorlbl.frame=CGRectMake(10, 125,Orwidth, 100);
        
        AddOpVendorBtn.frame=CGRectMake(Addvendorlbl.frame.size.width, 150,Orwidth+10, 40);
        
        OpVendorslistTable .frame= CGRectMake(Addvendorlbl.frame.size.width, 50,Orwidth+10, 100);
        OrderingInfoTable.frame = CGRectMake(10, 200,OrderingInfoView.frame.size.width-20, 300);
        SaveOrderingInfoBtn.frame=CGRectMake(Orwidth+120,540,80,30);
        CancelOrderingInfoBtn.frame=CGRectMake(Orwidth+220,540,80,30);
        
//Add Vendor Details View
        
        AddORVendorDetailsPopUp.frame=CGRectMake(0, 0, 768, 1024);
    //AddORVendordetailsView.frame=CGRectMake(200, 100, AddORVendorDetailsPopUp.frame.size.width-400, AddORVendorDetailsPopUp.frame.size.height-250);
        
        AddORVendordetailsView.frame=CGRectMake(100, 200, AddORVendorDetailsPopUp.frame.size.width-200, AddORVendorDetailsPopUp.frame.size.height-500);
        
        
        CGFloat Vendrowidth=(AddORVendordetailsView.frame.size.width)/2;
        CGFloat Vendor=Vendrowidth/2;
        AddVendorDetailsLbl.frame=CGRectMake(Vendor-40, 0,Vendrowidth-20, 100);
    
        int Ven=80;
        for (int i=0; i<4; i++)
        {
            
            UILabel *mylabel=(UILabel *)[AddORVendordetailsView viewWithTag:i+100];
            mylabel.frame=CGRectMake(Vendor-40, Ven,Vendrowidth+10, 40);
            [AddORVendordetailsView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[AddORVendordetailsView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(Vendor+mylabel.frame.size.width-130, Ven,Vendrowidth-60, 40);
            [AddORVendordetailsView addSubview:mytextfield];
            
            Ven=Ven+60;
            
        }
        
        Preferredlbl.frame=CGRectMake(Vendor-40, 320,Vendrowidth+10, 40);
        
        trueRadioBtn.frame=CGRectMake(Vendor+Preferredlbl.frame.size.width-130, 325,25, 25);
        
        Truelbl.frame=CGRectMake(Vendor+Preferredlbl.frame.size.width-130+42, 320,Vendrowidth-100,45 );
        
        falseRadioBtn.frame=CGRectMake(Vendor+OrVendorlbl.frame.size.width-220+Truelbl.frame.size.width, 325,25, 25);
        
        falselbl.frame=CGRectMake(Vendor+OrVendorlbl.frame.size.width-220+Truelbl.frame.size.width+42, Ven,Vendrowidth-60, 40);
        
        SaveORVendorDetailsBtn.frame=CGRectMake(Vendrowidth-80, 400, 80, 30);
        CancelORVendorDetailsBtn.frame=CGRectMake(Vendrowidth+60, 400, 80, 30);
        
 //product category view
        
        Pcategorypopup.frame=CGRectMake(0, 0, 768, 1024);
        
        PCategorysTable.frame=CGRectMake(100,200 ,Pcategorypopup.frame.size.width-200, Pcategorypopup.frame.size.height-400);
        
    
       // Pdeaprtmentpopup.frame=CGRectMake(0, 0, 1024, 768);
        Pdeaprtmentpopup.frame=CGRectMake(0, 0, 768, 1024);
        
        PdepartmentsTable.frame=CGRectMake(100,200 ,Pdeaprtmentpopup.frame.size.width-200, Pdeaprtmentpopup.frame.size.height-400);
        
        
//sales history view
        
       // HistoryPopupView.frame=CGRectMake(0, 0, 1024, 768);
        
        HistoryPopupView.frame=CGRectMake(0, 0, 768, 1024);
        
       // HistoryView.frame=CGRectMake(50, 100, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-200);
        
        HistoryView.frame=CGRectMake(50, 150, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-400);
        
        CGFloat widthfield14=(HistoryView.frame.size.width)/4;
        
        Historytextlbl.frame=CGRectMake(widthfield14+120,10,widthfield14,40);
        
        
        SalesHistoryTable .frame= CGRectMake(10,60,HistoryView.frame.size.width-20, 400);
        saveHistoryBtn.frame=CGRectMake(widthfield14+160,500,80,30);
    }
}

-(void)menuclicked
{
    if (menuslected == false){
        logoBtn.hidden=YES;
        // //NSLog(@"called");
        // //NSLog(@"%d",menuslected);
        menuslected=YES;
        
        
        //[UIView beginAnimations:nil context:NULL];
        //[UIView setAnimationDuration:1.0f];
        sidemenu.transform = CGAffineTransformMakeTranslation(0,0);
        //[SideMenuView setBackgroundColor:[UIColor whiteColor]];
        //sidemenu.hidden=NO;
        //[UIView commitAnimations];
        [backgroundcolorview addSubview:sidemenu];
        
       // [UIView beginAnimations:nil context:NULL];
       // [UIView setAnimationDuration:0.9f];
        menubutton.transform = CGAffineTransformMakeTranslation(180,0);
        
        menubutton.transform = CGAffineTransformRotate( menubutton.transform, - M_PI);
       // [UIView commitAnimations];
       // [UIView beginAnimations:nil context:NULL];
        //[UIView setAnimationDuration:1.0f];
        
        
    }else{
        logoBtn.hidden=NO;
        menuslected=NO;
        
       // [UIView beginAnimations:nil context:NULL];
       // [UIView setAnimationDuration:1.0f];
        sidemenu.transform = CGAffineTransformMakeTranslation(-250,0);
        
       // [UIView commitAnimations];
           
        //[UIView beginAnimations:nil context:NULL];
        //[UIView setAnimationDuration:1.0f];
        menubutton.transform = CGAffineTransformMakeTranslation(0,0);
        
        
        //[UIView commitAnimations];
        //[UIView beginAnimations:nil context:NULL];
        //[UIView setAnimationDuration:1.0f];
        
    }
    
}

/*-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    
    logoBtn.hidden=NO;
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.8f];
    mainview.transform = CGAffineTransformMakeTranslation(0,0);
    
    
    [UIView commitAnimations];
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.8f];
    sidemenu.transform = CGAffineTransformMakeTranslation(-250,0);
    //[SideMenuView setBackgroundColor:[UIColor whiteColor]];
    
    [UIView commitAnimations];
    [UIView commitAnimations];
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.0f];
    menubutton.transform = CGAffineTransformMakeTranslation(0,0);
    
    
    [UIView commitAnimations];
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.0f];
    menuslected=NO;
}*/


- (void) finishedSearching {
	[SearchField resignFirstResponder];
	SearchlistTable.hidden = YES;
}
-(void)helpiconclicked
{
    
}
-(void)logoutButtonClicked
{
      [serverSyncClassObject LogoutMethod];
    
    NSString *updateSQL =@"UPDATE miscellaneous SET userType=?,sessionId=?,userID=?";
    NSMutableArray *misUpdatearray=[[NSMutableArray alloc]initWithObjects:@"",@"",@"", nil];
    [[DataBaseManager dataBaseManager] executeRecordsWithQuery:updateSQL withArguments:misUpdatearray];
    [self.navigationController popToRootViewControllerAnimated:NO];
    [self releaseViews];
    [generalDataObject  releasevariable];
}

-(void)categotybuttonclicked:(UIButton *)sender
{
    NSArray *viewS = [self.navigationController viewControllers];
    //NSLog(@"nav views %@",viewS);
    NSInteger selectedrow=sender.tag;
    if(selectedrow == 0){
        
        Home *homeview=[[Home alloc]initWithNibName:@"Home" bundle:Nil];
        NSString *returnvalue;
        NSInteger selectedview;
        for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
        {
            if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Home class]])
            {
                returnvalue=@"yes";
                selectedview=m;
                break;
            }
            
        }
        ////NSLog(@"%d",selectedview);
        if([returnvalue isEqualToString:@"yes"])
        {
            [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
           [self releaseViews];
        }else{
            
            [self.navigationController pushViewController:homeview animated:NO];
            [self releaseViews];
        }
        
    }else if(selectedrow == 5){
        if ([[generalDataObject  userType] isEqualToString:@"employee"])
        {
            if ([[generalDataObject  settings_permission] isEqualToString:@"yes"])
            {
                [sender setImage:[UIImage imageNamed:@"settingsactive2.png"] forState:UIControlStateNormal];
                NSString *returnvalue;
                NSInteger selectedview;
                Settings  *settingsview=[[Settings alloc]initWithNibName:@"Settings" bundle:Nil];
                for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
                {
                    if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Settings class]])
                    {
                        returnvalue=@"yes";
                        selectedview=m;
                        break;
                    }
                    
                }
                if([returnvalue isEqualToString:@"yes"])
                {
                    [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                    [self releaseViews];
                }else
                {
                    
                    [self.navigationController pushViewController:settingsview animated:NO];
                    [self releaseViews];
                }
                
            }else{
                
                UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
                
                [authalert show];
            }
        }else{
            [sender setImage:[UIImage imageNamed:@"settingsactive2.png"] forState:UIControlStateNormal];
            NSString *returnvalue;
            NSInteger selectedview;
            Settings  *settingsview=[[Settings alloc]initWithNibName:@"Settings" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Settings class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                [self.navigationController pushViewController:settingsview animated:NO];
                [self releaseViews];
            }
            
            
        }
        
        
    }else if(selectedrow == 8){
        NSString *returnvalue;
        NSInteger selectedview;
        Stores *storesview=[[Stores alloc]initWithNibName:@"Stores" bundle:Nil];
        for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
        {
            if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Stores class]])
            {
                returnvalue=@"yes";
                selectedview=m;
                break;
            }
            
        }
        if([returnvalue isEqualToString:@"yes"])
        {
            [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
            [self releaseViews];
        }else
        {
            
            [self.navigationController pushViewController:storesview animated:NO];
            [self releaseViews];
        }
        
    }else if(selectedrow == 1){
        if ([[generalDataObject  userType] isEqualToString:@"admin"])
        {
            NSString *returnvalue;
            NSInteger selectedview;
            Profile *profileview=[[Profile alloc]initWithNibName:@"Profile" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Profile class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                
                [self.navigationController pushViewController:profileview animated:NO];
                [self releaseViews];
            }
            
        }else{
            UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
            
            [authalert show];
            authalert=nil;
        }
    }else if(selectedrow == 3){
        
        if ([[generalDataObject  userType] isEqualToString:@"employee"])
        {
            if ([[generalDataObject  customer_permission] isEqualToString:@"yes"])
            {
                NSString *returnvalue;
                NSInteger selectedview;
                Customers *customersview=[[Customers alloc]initWithNibName:@"Customers" bundle:Nil];
                for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
                {
                    if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Customers class]])
                    {
                        returnvalue=@"yes";
                        selectedview=m;
                        break;
                    }
                    
                }
                if([returnvalue isEqualToString:@"yes"])
                {
                    [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                    [self releaseViews];
                }else
                {
                    
                    [self.navigationController pushViewController:customersview animated:NO];
                    [self releaseViews];
                }
                
            }else{
                
                UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
                
                [authalert show];
            }
        }else{
            
            NSString *returnvalue;
            NSInteger selectedview;
            Customers *customersview=[[Customers alloc]initWithNibName:@"Customers" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Customers class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                
                [self.navigationController pushViewController:customersview animated:NO];
                [self releaseViews];
            }
        }
        
    }else if(selectedrow == 4){
        if ([[generalDataObject  userType] isEqualToString:@"admin"])
        {
            NSString *returnvalue;
            NSInteger selectedview;
            Employees *employeesview=[[Employees alloc]initWithNibName:@"Employees" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Employees class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                
                [self.navigationController pushViewController:employeesview animated:NO];
                [self releaseViews];
            }
            
        }
        else
        {
            UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
            
            [authalert show];
        }
        
    }else if(selectedrow == 6){
        
        if ([[generalDataObject  userType] isEqualToString:@"employee"])
        {
            if ([[generalDataObject  settings_permission] isEqualToString:@"yes"])
            {
                NSString *returnvalue;
                NSInteger selectedview;
                Reports *reportsview=[[Reports alloc]initWithNibName:@"Reports" bundle:Nil];
                for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
                {
                    if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Reports class]])
                    {
                        returnvalue=@"yes";
                        selectedview=m;
                        break;
                    }
                    
                }
                if([returnvalue isEqualToString:@"yes"])
                {
                    [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                    [self releaseViews];
                }else
                {
                    
                    [self.navigationController pushViewController:reportsview animated:NO];
                    [self releaseViews];
                }
                
            }else{
                
                UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
                
                [authalert show];
            }
        }else{
            
            NSString *returnvalue;
            NSInteger selectedview;
            Reports *reportsview=[[Reports alloc]initWithNibName:@"Reports" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Reports class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                
                [self.navigationController pushViewController:reportsview animated:NO];
                [self releaseViews];
            }
            
        }
        
    }else if(selectedrow == 7){
        NSString *returnvalue;
        NSInteger selectedview;
        Contacts *contactsview=[[Contacts alloc]initWithNibName:@"Contacts" bundle:Nil];
        for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
        {
            if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Contacts class]])
            {
                returnvalue=@"yes";
                selectedview=m;
                break;
            }
            
        }
        if([returnvalue isEqualToString:@"yes"])
        {
            [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
            [self releaseViews];
        }else
        {
            
            [self.navigationController pushViewController:contactsview animated:NO];
            [self releaseViews];
        }
    }
       
}

-(void)releaseViews
{
    NSArray *mainArray = self.view.subviews;
    for (int i = 0; i<[mainArray count]; i++) {
        UIView *vi =[mainArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *sideArray = sidemenu.subviews;
    for (int i = 0; i<[sideArray count]; i++) {
        UIView *vi =[sideArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *navBarArray = navBar.subviews;
    for (int i = 0; i<[navBarArray count]; i++) {
        UIView *vi =[navBarArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *productArray = ProductView.subviews;
    for (int i = 0; i<[productArray count]; i++) {
        UIView *vi =[productArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *AddProductArray = AddProductScrollView.subviews;
    for (int i = 0; i<[AddProductArray count]; i++) {
        UIView *vi =[AddProductArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *EditProductArray = EditProductBackView.subviews;
    for (int i = 0; i<[EditProductArray count]; i++) {
        UIView *vi =[EditProductArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [sidemenu removeFromSuperview],[mainview removeFromSuperview],[backgroundcolorview removeFromSuperview],[ProductView removeFromSuperview],[AddProductScrollView removeFromSuperview],[EditProductBackView removeFromSuperview];
    sidemenu=nil,mainview=nil,backgroundcolorview=nil;
    categorybutton=nil;
     downtoolBar=nil,maintoolBar=nil;
    logobackview=nil,logoimageview=nil;

    
    helpiconButton=nil,logouticonButton=nil,menubutton=nil;
   
    ProductBtn=nil,CategoryBtn=nil,DepartmentsBtn=nil,VendorsBtn=nil;
    navBar=nil;
    //category view
    NSArray * addCategoryArray = addCategoryBackView.subviews;
    for (int i = 0; i<[addCategoryArray count]; i++) {
        UIView *vi =[addCategoryArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addCategoryViewArray = addCategoryView.subviews;
    for (int i = 0; i<[addCategoryViewArray count]; i++) {
        UIView *vi =[addCategoryViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addCategoryView removeFromSuperview],[addCategoryBackView removeFromSuperview];
    addCategoryBackView=nil;
    addCategoryView=nil;
    editCategoryTable=nil;
    // add category view
    categoryidField=nil;
    catIDlbl=nil,catdesLbl=nil;
    catDesField=nil;
    saveCategoryBtn=nil,cancelcatBtn=nil,addcategoryBtn=nil,EditCategoryBtn=nil;
    editBtn=nil,deleteBtn=nil;
  
    deletecategoryAlert=nil;
    [updateTableArray removeAllObjects],[updateTableArray2 removeAllObjects];
    updateTableArray=nil,updateTableArray2=nil;
    [categoryIdsArray removeAllObjects],[categorynamesArray removeAllObjects],[categoryDesArray removeAllObjects];
    categoryIdsArray=nil,categorynamesArray=nil,categoryDesArray=nil;
    
    //category edit view
    NSArray * editCatpopupviewArray = editCatpopupview.subviews;
    for (int i = 0; i<[editCatpopupviewArray count]; i++) {
        UIView *vi =[editCatpopupviewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *EditCategoryViewArray = EditCategoryView.subviews;
    for (int i = 0; i<[EditCategoryViewArray count]; i++) {
        UIView *vi =[EditCategoryViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditCategoryView removeFromSuperview],[editCatpopupview removeFromSuperview];
    editCatpopupview=nil,EditCategoryView=nil;
    ChangecategoryidField=nil;
    ChnagecatIDlbl=nil,ChangecatdesLbl=nil;
    ChengecatDesField=nil;
    ChangesaveCategoryBtn=nil,ChangecancelcatBtn=nil,ChangeaddcategoryBtn=nil,ChangeEditCategoryBtn=nil;
    nameCat=nil,CatDes=nil;
    
    //Department view
    
    NSArray * depertmentViewArray = depertmentView.subviews;
    for (int i = 0; i<[depertmentViewArray count]; i++) {
        UIView *vi =[depertmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addDepartmentViewArray = addDepartmentView.subviews;
    for (int i = 0; i<[addDepartmentViewArray count]; i++) {
        UIView *vi =[addDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
      [addDepartmentView removeFromSuperview],[depertmentView removeFromSuperview];
    depertmentView=nil;
    //add deparment
    addDepartmentView=nil;
    addDeptbtn=nil,Editdeptbtn=nil;
    CatforthisDeptBtn=nil;
    IDfield=nil;
    deptIDlbl=nil,deptdesLbl=nil,deptcatidlbl=nil;
    deptDestextView=nil;
    savedeptBtn=nil,canceldeptbtn=nil;
    EditDeptTable=nil;
    categorysListTable=nil,PrinterslistTable=nil;
    [departmentIDsArray removeAllObjects],[DepartmentDesArray removeAllObjects],[DepartmentNamesArray removeAllObjects],[DeptCatIdsArray removeAllObjects],[deptprintersArray removeAllObjects],[deptfoodsArray removeAllObjects],[depttaxesArray removeAllObjects];
    departmentIDsArray=nil,DepartmentNamesArray=nil,DepartmentDesArray=nil,DeptCatIdsArray=nil,deptprintersArray=nil,deptfoodsArray=nil,depttaxesArray=nil;
    dataEditBtn=nil,dataDeleteBtn=nil,DuplicateBtn=nil;
    Deptax1Btn=nil,Deptax2Btn=nil,Deptax3Btn=nil,DepBarTaxBtn=nil,DeptfoodstampleBtn=nil,DeptprinterBtn=nil;
    Deptax1lbl=nil,Deptax2lbl=nil,Deptax3lbl=nil,Depbartaxlbl=nil,DeptFoodstampablelbl=nil,Deptprinterlbl=nil;
    deleteDeptAlert=nil;
    DepTaxValueStr=nil,Deptfoodstampable=nil;
    [PrinterslistArray removeAllObjects],[MinitsArray removeAllObjects];
    PrinterslistArray=nil;
    MinitsArray=nil;
    TimeForDeptlbl=nil;
    MinitBtn=nil,SecsBtn=nil;
    MinitslistTable=nil,SecslistTable=nil;
    [TimesArray removeAllObjects];
    TimesArray=nil;
    
    //edit department
    NSArray * editDepartmentpopupArray = editDepartmentpopup.subviews;
    for (int i = 0; i<[editDepartmentpopupArray count]; i++) {
        UIView *vi =[editDepartmentpopupArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *EditDepartmentViewArray = EditDepartmentView.subviews;
    for (int i = 0; i<[EditDepartmentViewArray count]; i++) {
        UIView *vi =[EditDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditDepartmentView removeFromSuperview],[editDepartmentpopup removeFromSuperview];
    EditDepartmentView=nil;
    editDepartmentpopup=nil;
    ChangeaddDeptbtn=nil,ChangeEditdeptbtn=nil;
    ChangeCatforthisDeptBtn=nil;
    ChangeIDfield=nil;
    ChangecategorysListTable=nil,ChangePrinterslistTable=nil;
    ChangedeptIDlbl=nil,ChangedeptdesLbl=nil,Changedeptcatidlbl=nil;
    ChangedeptDestextView=nil;
    ChangesavedeptBtn=nil,Changecanceldeptbtn=nil;
    nameDept=nil,idDept=nil,desDept=nil;
    ChangedataEditBtn=nil,ChangedataDeleteBtn=nil,ChangeDuplicateBtn=nil;
    ChangeDeptax1Btn=nil,ChangeDeptax2Btn=nil,ChangeDeptax3Btn=nil,ChangeDepBarTaxBtn=nil,ChangeDeptfoodstampleBtn=nil,ChangeDeptprinterBtn=nil;
    ChangeDeptax1lbl=nil,ChangeDeptax2lbl=nil,ChangeDeptax3lbl=nil,ChangeDepbartaxlbl=nil,ChangeDeptFoodstampablelbl=nil,ChangeDeptprinterlbl=nil;
    EditDeptfoodstampable=nil;
    
    ChangeTimeForDeptlbl=nil;
    ChangeMinitBtn=nil,ChangeSecsBtn=nil;
    ChangeMinitslistTable=nil,ChangeSecslistTable=nil;
    
    
    //Duplicate department view
    NSArray *DuplicateDepartmentpopupArray = DuplicateDepartmentpopup.subviews;
    for (int i = 0; i<[DuplicateDepartmentpopupArray count]; i++) {
        UIView *vi =[DuplicateDepartmentpopupArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *DuplicateDepartmentViewArray = DuplicateDepartmentView.subviews;
    for (int i = 0; i<[DuplicateDepartmentViewArray count]; i++) {
        UIView *vi =[DuplicateDepartmentViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [DuplicateDepartmentView removeFromSuperview],[DuplicateDepartmentpopup removeFromSuperview];
    DuplicateDepartmentpopup=nil;
    DuplicateDepartmentView=nil;
    DuplicateCatforthisDeptBtn=nil;
    DuplicateIDfield=nil;
    DuplicatedeptIDlbl=nil,DuplicatedeptdesLbl=nil,Duplicatedeptcatidlbl=nil;
    DuplicatedeptDestextView=nil;
    DuplicatesavedeptBtn=nil,Duplicatecanceldeptbtn=nil;
    DuplicateEditDeptTable=nil;
    DuplicatecategorysListTable=nil;
    DuplicateDeptax1Btn=nil,DuplicateDeptax2Btn=nil,DuplicateDeptax3Btn=nil,DuplicateDepBarTaxBtn=nil,DuplicateDeptfoodstampleBtn=nil,DuplicateDeptprinterBtn=nil;
    DuplicateDeptax1lbl=nil,DuplicateDeptax2lbl=nil,DuplicateDeptax3lbl=nil,DuplicateDepbartaxlbl=nil,DuplicateDeptFoodstampablelbl=nil,DuplicateDeptprinterlbl=nil;
    DuplicatePrinterslistTable=nil;
    
    DuplicateTimeForDeptlbl=nil;
    DuplicateMinitBtn=nil,DuplicateSecsBtn=nil;
    DuplicateMinitslistTable=nil,DuplicateSecslistTable=nil;
    
    //vendors view
    NSArray *vendorsViewArray = vendorsView.subviews;
    for (int i = 0; i<[vendorsViewArray count]; i++) {
        UIView *vi =[vendorsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *AddvendorsViewArray = AddvendorsView.subviews;
    for (int i = 0; i<[AddvendorsViewArray count]; i++) {
        UIView *vi =[AddvendorsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [AddvendorsView removeFromSuperview],[vendorsView removeFromSuperview];
    vendorsView=nil;
    AddvendorsView=nil;
    
    AddvendorBtn=nil,EditvendorBtn=nil;
    generalinfolbl=nil,Addresslbl=nil;
    GeneralinfoField=nil,AddressField=nil;
    InfotextLbl=nil,AddresstextLbl=nil;
    DeliverymethodBtn=nil;
    DeliveryTypesTable=nil;
    SaveVendorsBtn=nil,CancelVendorBtn=nil;
    EditVendorTable=nil;
    
    DeliverymethodsArray=nil;
    polbl=nil;
    vendorNO=nil,Terms=nil,minimumOrder=nil,commission=nil,Companyname=nil,FlatRent=nil,TaxtID=nil,Billable=nil,Socialsecurity=nil,streetAddress=nil,ExtendedAddress=nil,City=nil,state=nil,Zipcode=nil,country=nil,firstname=nil,lastname=nil,phNUmber=nil,faxnumber=nil,email=nil,website=nil;
    //edit vvendor view
    Editvendor=nil,DeleteVendor=nil;
    [VendornumbersArray removeAllObjects],[termsArray removeAllObjects],[minimumorderArray removeAllObjects],[companyNAmesArray removeAllObjects],[flatrentsArray removeAllObjects],[TaxidsArray removeAllObjects],[billablesArray removeAllObjects],[socialsArray removeAllObjects],[podeliverysArray removeAllObjects],[streetaddressArray removeAllObjects],[exteddedArray removeAllObjects],[streetsArray removeAllObjects],[citysArray removeAllObjects],[statesArray removeAllObjects],[ZipcodesArray removeAllObjects],[countrysArray removeAllObjects],[firstnamesArray removeAllObjects],[lastnamesArray removeAllObjects],[phnumbersArray removeAllObjects],[faxesArray removeAllObjects],[emailsArray removeAllObjects],[websitesArray removeAllObjects];
  
    VendornumbersArray=nil,termsArray=nil,minimumorderArray=nil,commission=nil,companyNAmesArray=nil,flatrentsArray=nil,TaxidsArray=nil,billablesArray=nil,socialsArray=nil,podeliverysArray=nil,streetaddressArray=nil,exteddedArray=nil,streetsArray=nil,citysArray=nil,statesArray=nil,ZipcodesArray=nil,countrysArray=nil,firstnamesArray=nil,lastnamesArray=nil,phnumbersArray=nil,faxesArray=nil,emailsArray=nil,websitesArray=nil;
    deletevendorAlert=nil;
    NSArray *EditVendorPopupArray = EditVendorPopup.subviews;
    for (int i = 0; i<[EditVendorPopupArray count]; i++) {
        UIView *vi =[EditVendorPopupArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *EditvendorScrollViewArray = EditvendorScrollView.subviews;
    for (int i = 0; i<[EditvendorScrollViewArray count]; i++) {
        UIView *vi =[EditvendorScrollViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditvendorScrollView removeFromSuperview],[EditVendorPopup removeFromSuperview];
    EditVendorPopup=nil;
    EditvendorScrollView=nil;
    changepolbl=nil;
    chnagegeneralinfolbl=nil,changeAddresslbl=nil;
    chnageGeneralinfoField=nil,chnageAddressField=nil;
    chnageInfotextLbl=nil,chnageAddresstextLbl=nil;
    changeDeliverymethodBtn=nil;
    changeDeliveryTypesTable=nil;
    changeSaveVendorsBtn=nil,changeCancelVendorBtn=nil;
    ChangevendorNO=nil,ChangeTerms=nil,ChangeminimumOrder=nil,Changecommission=nil,ChangeCompanyname=nil,ChangeFlatRent=nil,ChangeTaxtID=nil,ChangeBillable=nil,ChangeSocialsecurity=nil,ChangestreetAddress=nil,ChangeExtendedAddress=nil,ChangeCity=nil,Changestate=nil,ChangeZipcode=nil,Changecountry=nil,Changefirstname=nil,Changelastname=nil,ChangephNUmber=nil,Changefaxnumber=nil,Changeemail=nil,Changewebsite=nil;

    
    //product view
    
    ProductView=nil;
    //add product view
    AddProductScrollView=nil;
    AddProductBtn=nil,EditProductBtn=nil;
    DepartmentBtn=nil,SaveProductBtn=nil,CancelProductBtn=nil,tax1Btn=nil,tax2Btn=nil,tax3Btn=nil,BarTaxBtn=nil,PriceWithTaxBtn=nil,AddpricingBtn=nil;
    DescriptionText=nil;
    ItemNumberField=nil,ItemNameField=nil,CostField=nil,PriceyouChargeField=nil,InStockField=nil;
    Departmentlbl=nil,ItemNumberlbl=nil,ItemNamelbl=nil,Descroptionlbl=nil,datalbl=nil,pricinglbl=nil,tax1lbl=nil,tax2lbl=nil,tax3lbl=nil,bartaxlbl=nil,Costlbl=nil,priceyouChargelbl=nil,priceWithTaxlbl=nil,InStocklbl=nil,Addpricinglbl=nil;
    DepartmentsTable=nil,VendorsTable=nil;
    Tax=nil;
    
    //optionalinfo view
    NSArray *OptionalInfoBackViewArray = OptionalInfoBackView.subviews;
    for (int i = 0; i<[OptionalInfoBackViewArray count]; i++) {
        UIView *vi =[OptionalInfoBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *OptionalInfoViewArray = OptionalInfoView.subviews;
    for (int i = 0; i<[OptionalInfoViewArray count]; i++) {
        UIView *vi =[OptionalInfoViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [OptionalInfoView removeFromSuperview],[OptionalInfoBackView removeFromSuperview];
    OptionalInfoView=nil,OptionalInfoBackView=nil;
    OptionalinfoFields=nil;
    optCommissionBtn=nil,ItemBtn=nil,OptionalinfoSaveBtn=nil,OptionalinfoCancelBtn=nil,AddskuBtn=nil;
    Optionalinfolbl=nil,OptCommissonlbl=nil,Alternatelbl=nil,tagAlongitemlbl=nil,Itemlbl=nil,OptionalinfoTextLbl=nil;
    AlternateTable=nil,TagAlongitemtable=nil,CommissionsTable=nil;
    modifierItem=nil,CountthisItem=nil,allowbuyback=nil,printonreceipt=nil,foodstampable=nil,Promptprice=nil;
    
     [modifierItemsArray removeAllObjects],[CountthisitemsArray removeAllObjects],[allowbuybackArray removeAllObjects],[printonreciptArray removeAllObjects],[foodstampableArray removeAllObjects],[promptpricesArray removeAllObjects],[OpBonuspointsArray removeAllObjects],[OpBarcodesArray removeAllObjects],[OpunisizesArray removeAllObjects],[OpunittypesArray removeAllObjects],[OpcommisArray removeAllObjects];
    modifierItemsArray=nil,CountthisitemsArray=nil,allowbuybackArray=nil,printonreciptArray=nil,foodstampableArray=nil,promptpricesArray=nil,OpBonuspointsArray=nil,OpBarcodesArray=nil,OpunisizesArray=nil,OpunittypesArray=nil,OpcommisArray=nil;
    
    OPBonusPoints=nil,OPBarcodes=nil,OPunittype=nil,OPunitsize=nil,OPlocation=nil,OPCommission=nil;
    //edit optional info view
    EditmodifierItem=nil,EditCountthisItem=nil,Editallowbuyback=nil,Editprintonreceipt=nil,Editfoodstampable=nil,Editpromptprice=nil;
    modifierItemStr=nil,countthisitemStr=nil,allowbuybackStr=nil,printonReceiptStr=nil,foodstampableStr=nil,PromptpriceStr=nil;
    Editbonuspoint=nil,Editbarcode=nil,Editlocation=nil,Editunitsize=nil,EditUnittype=nil,Editcommission=nil;
    
    //add sku's view
    NSArray *AddskupopupViewArray = AddskupopupView.subviews;
    for (int i = 0; i<[AddskupopupViewArray count]; i++) {
        UIView *vi =[AddskupopupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *addskuViewArray = addskuView.subviews;
    for (int i = 0; i<[addskuViewArray count]; i++) {
        UIView *vi =[addskuViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [addskuView removeFromSuperview],[AddskupopupView removeFromSuperview];
    [allSkusArray removeAllObjects],[SelectedSkusArray removeAllObjects];
    allSkusArray=nil,SelectedSkusArray=nil;
    AddskupopupView=nil,addskuView=nil;
    skuTextlbl=nil;
    SkuField=nil;
    saveSkuBtn=nil,CancelSkuBtn=nil,DeleteSkuBtn=nil;
    [SkusArray removeAllObjects];
    SkusArray=nil; SkuStr=nil;
    
    
    //Pending Orders
    NSArray *PendingOrderBackViewArray = PendingOrderBackView.subviews;
    for (int i = 0; i<[PendingOrderBackViewArray count]; i++) {
        UIView *vi =[PendingOrderBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *PendingOrderViewArray = PendingOrderView.subviews;
    for (int i = 0; i<[PendingOrderViewArray count]; i++) {
        UIView *vi =[PendingOrderViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [PendingOrderView removeFromSuperview],[PendingOrderBackView removeFromSuperview];
    PendingOrderBackView=nil,PendingOrderView=nil;
    openlbl=nil,completelbl=nil,cancellbl=nil,PendingOrderTextlbl=nil;
    OpenRadioBtn=nil,CompleteRadioBtn=nil,CancelRadioBtn=nil,CompletethisorderBtn=nil,cancelthisOrderBtn=nil,SavePendingorderBtn=nil,CancelPendingorderBtn=nil;
    PendingOrdersTable=nil;
    //Notes View
    NSArray *NotesBackViewArray = NotesBackView.subviews;
    for (int i = 0; i<[NotesBackViewArray count]; i++) {
        UIView *vi =[NotesBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *NotesViewArray = NotesView.subviews;
    for (int i = 0; i<[NotesViewArray count]; i++) {
        UIView *vi =[NotesViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [NotesView removeFromSuperview],[NotesBackView removeFromSuperview];
    NotesBackView=nil,NotesView=nil;
    NotesTextView=nil;
    Notestextlbl=nil;
    SaveNotesBtn=nil,CancelNotesBtn=nil;
    Productnotes=nil; productNotesArray=nil;
    
    //edit Notes view
    EditProductNotes=nil,productnotesStr=nil;
    DuplicateproductNotes=nil;
    
    
    
    //Future Change of modifier View
    
    //Modifier View
    ModifierBackView=nil,ModifierView=nil,ModifierGroupView=nil;
    GroupRadioBtn=nil,IndividualRadioBtn=nil,SaveGroupModifierBtn=nil,CancelGroupModifierBtn=nil,ChargeforModifierBtn=nil,ForceBtn=nil,ToSelectBtn=nil,AddModifierGroupBtn=nil,AddModifierBtn=nil,SaveIndividualBtn=nil,CancelIndividualBtn=nil;
    Grouplbl=nil,individuallbl=nil,Toselectlbl=nil,ModifierDeslbl=nil,promptlbl=nil,chargeforModifierlbl=nil,Forcelbl=nil,ModifierTextlbl=nil;
    ModifierDesField=nil,PromptField=nil;
    ModifierGroupTable=nil,ModifierIndividualTable=nil,ToSelectTable=nil;
    ModIndividualView=nil;
    
    
    //modifier view
    
    //present modifier view
    NSArray *modBackViewArray = modBackView.subviews;
    for (int i = 0; i<[modBackViewArray count]; i++) {
        UIView *vi =[modBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *modViewArray = modView.subviews;
    for (int i = 0; i<[modViewArray count]; i++) {
        UIView *vi =[modViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [modView removeFromSuperview],[modBackView removeFromSuperview];

    modBackView=nil,modView=nil;
    ModifieritemsDropdownBtn=nil,SavemodBtn=nil,CancelModBtn=nil,DeleteItemNo=nil;
    ItemsListTable=nil,modifierItemsTable=nil;
    modTextlbl=nil;
    [itemsListArray removeAllObjects];
   [ModifierItemNosArray removeAllObjects],[modifierNamesArray removeAllObjects],[NamesArray removeAllObjects],[Allmodifiers removeAllObjects],[selectedModifiers removeAllObjects],[SelectedNamesArray removeAllObjects];
    itemsListArray=nil;
    ModifierItemNosArray=nil,modifierNamesArray=nil,NamesArray=nil,Allmodifiers=nil,selectedModifiers=nil,SelectedNamesArray=nil;
    
    
    //price levels view
    NSArray *PriceLevelsBackViewArray = PriceLevelsBackView.subviews;
    for (int i = 0; i<[PriceLevelsBackViewArray count]; i++) {
        UIView *vi =[PriceLevelsBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *PriceLevelsViewArray = PriceLevelsView.subviews;
    for (int i = 0; i<[PriceLevelsViewArray count]; i++) {
        UIView *vi =[PriceLevelsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [PriceLevelsView removeFromSuperview],[PriceLevelsBackView removeFromSuperview];
    PriceLevelsBackView=nil,PriceLevelsView=nil;
    PriceLevelsTable=nil;
    PriceLevelTextlbl=nil;
    SavePriceLevelLbl=nil,CancelPricelevelbtn=nil;
    
    [ProductDepartmentsArray removeAllObjects],[ItemNumbersArray removeAllObjects],[ItemnameArray removeAllObjects],[productDesArray removeAllObjects],[CostArray removeAllObjects],[priceyouchargeArray removeAllObjects],[pricewithTaxArray removeAllObjects],[InstockArray removeAllObjects],[productVendorsArray removeAllObjects],[taxvaluesArray removeAllObjects];
    
    ProductDepartmentsArray=nil,ItemNumbersArray=nil,ItemnameArray=nil,productDesArray=nil,CostArray=nil,priceyouchargeArray=nil,pricewithTaxArray=nil,InstockArray=nil,productVendorsArray=nil,taxvaluesArray=nil;
    
    //Ordering View
    NSArray *OrderingInfoBackViewArray = OrderingInfoBackView.subviews;
    for (int i = 0; i<[OrderingInfoBackViewArray count]; i++) {
        UIView *vi =[OrderingInfoBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *OrderingInfoViewArray = OrderingInfoView.subviews;
    for (int i = 0; i<[OrderingInfoViewArray count]; i++) {
        UIView *vi =[OrderingInfoViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [OrderingInfoView removeFromSuperview],[OrderingInfoBackView removeFromSuperview];
    OrderingInfoBackView=nil;
    OrderingInfoView=nil;
    AddOpVendorBtn=nil;
    Addvendorlbl=nil;
    OrderingInfoTable=nil,OpVendorslistTable=nil;
    SaveOrderingInfoBtn=nil,CancelOrderingInfoBtn=nil;
    [OpVendorsArray removeAllObjects],[SelectedOpVendorsArray removeAllObjects];
    OpVendorsArray=nil;
    SelectedOpVendorsArray=nil;
    EditOrderingInfoBtn=nil,DeleteOrderingInfoBtn=nil;
    OrderingInfotextLbl=nil;
    //Order Vendor Details View
    NSArray *AddORVendorDetailsPopUpArray = AddORVendorDetailsPopUp.subviews;
    for (int i = 0; i<[AddORVendorDetailsPopUpArray count]; i++) {
        UIView *vi =[AddORVendorDetailsPopUpArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *AddORVendordetailsViewArray = AddORVendordetailsView.subviews;
    for (int i = 0; i<[AddORVendordetailsViewArray count]; i++) {
        UIView *vi =[AddORVendordetailsViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [AddORVendordetailsView removeFromSuperview],[AddORVendorDetailsPopUp removeFromSuperview];
    AddORVendorDetailsPopUp=nil;
    AddORVendordetailsView=nil;
    AddVendorDetailsLbl=nil,OrVendorlbl=nil;
    VendorField=nil;
    SaveORVendorDetailsBtn=nil,CancelORVendorDetailsBtn=nil;
    VendorpartStr=nil,CostperStr=nil,CaseCostStr=nil,Numberincasestr=nil;
    Preferredlbl=nil,Truelbl=nil,falselbl=nil;
    trueRadioBtn=nil,falseRadioBtn=nil;
    PreferredStr=nil;
    [VendorpartNosArray removeAllObjects];
    VendorpartNosArray=nil;
    
    [VendorPartsArray removeAllObjects],[CostpersArray removeAllObjects],[CasecostsArray removeAllObjects],[NumberincasesArray removeAllObjects],[preferredsArray removeAllObjects];
    VendorPartsArray=nil,CostpersArray=nil,CasecostsArray=nil,NumberincasesArray=nil,preferredsArray=nil;
    
    
    //edit product view
    editProductTable=nil;
    EditProductButton=nil,DeleteProductBtn=nil,DuplicateProductBtn=nil,InstanpoBtn=nil;
    deleteProductAlert=nil;
   
    NSArray *EditproductPopUpViewArray = EditproductPopUpView.subviews;
    for (int i = 0; i<[EditproductPopUpViewArray count]; i++) {
        UIView *vi =[EditproductPopUpViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *EditProductViewArray = EditProductView.subviews;
    for (int i = 0; i<[EditProductViewArray count]; i++) {
        UIView *vi =[EditProductViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [EditProductView removeFromSuperview],[EditproductPopUpView removeFromSuperview];
    EditproductPopUpView=nil;
    EditProductView=nil;
    
    ChangeDepartmentBtn=nil,ChangeSaveProductBtn=nil,ChangeCancelProductBtn=nil,Changetax1Btn=nil,Changetax2Btn=nil,Changetax3Btn=nil,ChangeBarTaxBtn=nil,ChangePriceWithTaxBtn=nil,ChangeAddpricingBtn=nil;
    ChangeDescriptionText=nil;
    ChangeItemNumberField=nil,ChangeItemNameField=nil,ChangeCostField=nil,ChangePriceyouChargeField=nil,ChangeInStockField=nil;
    ChangeDepartmentlbl=nil,ChangeItemNumberlbl=nil,ChangeItemNamelbl=nil,ChangeDescroptionlbl=nil,Changedatalbl=nil,Changepricinglbl=nil,Changetax1lbl=nil,Changetax2lbl=nil,Changetax3lbl=nil,Changebartaxlbl=nil,ChangeCostlbl=nil,ChangepriceyouChargelbl=nil,ChangepriceWithTaxlbl=nil,ChangeInStocklbl=nil,ChangeAddpricinglbl=nil;
    ChangeDepartmentsTable=nil,ChangeVendorsTable=nil;
    
    infoButtons=nil,infoButton2=nil;
  
    costStr=nil,TaxValueStr=nil;
    tax1Str=nil,tax2Str=nil,tax3Str=nil,bartaxStr=nil,totalTaxStr=nil;
   
    Changetax1Str=nil,Changetax2Str=nil,Changetax3Str=nil,ChangebartaxStr=nil,ChangetotalTaxStr=nil;
   
    ChangecostStr=nil,ChangeTaxValueStr=nil;
    ChangeinfoButtons=nil,ChangeinfoButton2=nil;
    
    
    //Duplicate product view
    NSArray *DuplicateproductPopUpViewArray = DuplicateproductPopUpView.subviews;
    for (int i = 0; i<[DuplicateproductPopUpViewArray count]; i++) {
        UIView *vi =[DuplicateproductPopUpViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *DuplicateProductViewArray = DuplicateProductView.subviews;
    for (int i = 0; i<[DuplicateProductViewArray count]; i++) {
        UIView *vi =[DuplicateProductViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [DuplicateProductView removeFromSuperview],[DuplicateproductPopUpView removeFromSuperview];
    DuplicateproductPopUpView=nil;
    DuplicateProductView=nil;
    
    DuplicateDepartmentBtn=nil,DuplicateSaveProductBtn=nil,DuplicateCancelProductBtn=nil,Duplicatetax1Btn=nil,Duplicatetax2Btn=nil,Duplicatetax3Btn=nil,DuplicateBarTaxBtn=nil,DuplicatePriceWithTaxBtn=nil,DuplicateAddpricingBtn=nil;
    DuplicateDescriptionText=nil;
    DuplicateItemNumberField=nil,DuplicateItemNameField=nil,DuplicateCostField=nil,DuplicatePriceyouChargeField=nil,DuplicateInStockField=nil;
    DuplicateDepartmentlbl=nil,DuplicateItemNumberlbl=nil,DuplicateItemNamelbl=nil,DuplicateDescroptionlbl=nil,Duplicatedatalbl=nil,Duplicatepricinglbl=nil,Duplicatetax1lbl=nil,Duplicatetax2lbl=nil,Duplicatetax3lbl=nil,Duplicatebartaxlbl=nil,DuplicateCostlbl=nil,DuplicatepriceyouChargelbl=nil,DuplicatepriceWithTaxlbl=nil,DuplicateInStocklbl=nil,DuplicateAddpricinglbl=nil;
    DuplicateDepartmentsTable=nil,DuplicateVendorsTable=nil;
    
    DuplicateinfoButtons=nil,DuplicateinfoButton2=nil;
    //Instant po view
    NSArray *InstantPoPOPupViewArray = InstantPoPOPupView.subviews;
    for (int i = 0; i<[InstantPoPOPupViewArray count]; i++) {
        UIView *vi =[InstantPoPOPupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *InstantPOViewArray = InstantPOView.subviews;
    for (int i = 0; i<[InstantPOViewArray count]; i++) {
        UIView *vi =[InstantPOViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [InstantPOView removeFromSuperview],[InstantPoPOPupView removeFromSuperview];
    InstantPoPOPupView=nil,InstantPOView=nil;
    Instantpolbl=nil;
    InstantpoField=nil;
    SaveInstantPoBtn=nil,CancelInstantpoBtn=nil;
    
    
     CategoryConnection=nil,VendorConnection=nil,SkuConnection=nil,ModifierConnection=nil,OrderinfInfoConnection=nil;
     CatresponseData=nil,vendorResponseData=nil,SkuResponseData=nil,ModifierResponseData=nil,OrderinfInfoResponseData=nil;
    
    
    //product serach bar views
    NSArray *EditProductBackViewArray = EditProductBackView.subviews;
    for (int i = 0; i<[EditProductBackViewArray count]; i++) {
        UIView *vi =[EditProductBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
   [EditProductBackView removeFromSuperview];
    EditProductBackView=nil;
    
    Catlbl=nil,Deptlbl=nil,Searchlbl=nil,displaylbl=nil;
    Gobtn=nil,ResultspersetBtn=nil,CatField=nil,DeptField=nil;
    SearchField=nil;
    DisplaySettable=nil;
    
    
    //product category view
    NSArray *PcategorypopupArray = Pcategorypopup.subviews;
    for (int i = 0; i<[PcategorypopupArray count]; i++) {
        UIView *vi =[PcategorypopupArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [Pcategorypopup removeFromSuperview];
    Pcategorypopup=nil;
    PCategorysTable=nil;
    //Product department view
    Pdeaprtmentpopup=nil;
    PdepartmentsTable=nil;
    SearchlistTable=nil;
    [SearchDataArray removeAllObjects],[pastDataArray removeAllObjects];
    SearchDataArray=nil;
    pastDataArray=nil;
    
    SelectedResultsForSet=nil;
    
    //Hiestory View
    NSArray *HistoryPopupViewArray = HistoryPopupView.subviews;
    for (int i = 0; i<[HistoryPopupViewArray count]; i++) {
        UIView *vi =[HistoryPopupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [HistoryPopupView removeFromSuperview];
    NSArray *HistoryViewArray = HistoryView.subviews;
    for (int i = 0; i<[HistoryViewArray count]; i++) {
        UIView *vi =[HistoryViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [HistoryView removeFromSuperview];
    HistoryPopupView=nil,HistoryView=nil;
    Historytextlbl=nil;
    saveHistoryBtn=nil,CancelHistoryBtn=nil;
    
    SalesHistoryTable=nil;
    
    [itemIDArray removeAllObjects],[itemNameArray removeAllObjects],[discountArray removeAllObjects],[taxArray removeAllObjects],[yourCostArray removeAllObjects],[avgArray removeAllObjects],[quantityArray removeAllObjects],[dateArray removeAllObjects];

    itemIDArray=nil,itemNameArray=nil,discountArray=nil,taxArray=nil,yourCostArray=nil,avgArray=nil,quantityArray=nil,dateArray=nil;
    
    sationLbl=nil,Timelbl=nil,EmpIdlbl=nil;
    logoBtn=nil;
    
    [SnosArray removeAllObjects];
    SnosArray=nil;
    dataDict=nil;
    
    //taxes
    tax1Name=nil,tax2Name=nil,tax3Name=nil,tax1Rate=nil,tax2Rate=nil,tax3Rate=nil;
    
     productCell=nil;
     categoryCell=nil;
     departmentCell=nil;
     vendorCell=nil;
     inventorySalesCell=nil;
     orderingInfoCell=nil;
     modifierItemCell=nil;
    btnGreyImg=nil;
    [self.view removeFromSuperview];
    self.view=nil;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

{
    if (toInterfaceOrientation==UIInterfaceOrientationLandscapeRight||toInterfaceOrientation==UIInterfaceOrientationLandscapeLeft) {
        isLandScope=YES;
        
    }
    else
    {
        isLandScope=NO;
    }
    [self updateUI];
}

/*- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    
    for (UITableView *tv in [Pcategorypopup subviews]) {
        [tv removeFromSuperview];
    }
    [Pcategorypopup removeFromSuperview];
    for (UITableView *tv in [Pdeaprtmentpopup subviews]) {
        [tv removeFromSuperview];
    }
    [Pdeaprtmentpopup removeFromSuperview];
    
     [self duplicateProductViewremove];
    [self duplicateProductViewremove];
    [self editProductViewremoveMethod];
   [self Editdepartmentviewremove];
    [self editVendorViewRemove];
    [self editcategoryViewremove];
}*/

- (NSUInteger)supportedInterfaceOrientations // iOS 6 autorotation fix
{
    return UIInterfaceOrientationMaskAll;
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    NSArray *viewS = [self.navigationController viewControllers];
    [self.navigationController popToViewController:[viewS objectAtIndex:1] animated:YES];
    [self releaseViews];
    // Dispose of any resources that can be recreated.
}

@end
